I'm learning Go and I'm reading examples from libraries. I found that some examples are using:
type MyType struct {
Code string
//...
}
func main() {
myType := &MyType{...}
//...
myType = &MyType{...}
}
Basically they are reusing variables. I understand that &MyType{..}
returns a pointer, later I can replace that pointer. What happens with the previous pointed memory. Will the GC reclaim that memory or will I waste that memory. Maybe this is a silly question and I'm concerned for nothing but I'm trying to learn Go to build performance APIs :)