5 Answers
New AnswerVáclav Dostál I did this way: package main import "fmt" type Timer struct { id string seconds int } func main() { var x int fmt.Scanln(&x) t := Timer{"ABC", x} reset(&t) fmt.Println(t) } // my implementation is written below func reset(t *Timer) { t.seconds = 0 }
Previously I didn't know how to solve it, then I found this material in the following link with some examples and it helped me. https://tour.golang.org/methods/5
package main import "fmt" type Timer struct { id string seconds int } func reset(t *int) { //t := &Timer{Timer.name, 0} //*x = 0 } func main() { var x int fmt.Scanln(&x) t := Timer{"ABC", x} reset(&t) fmt.Println(t) }
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message