Read a blog about copying structs in GO. I don’t notice the same behavior in my tests. What am I missing ?

Written by
Link to Post by 

I don’t observe the copy-linking behaviour for structs containing complex types. The blog post is at this link What I am missing ?

I run a test here and with the testing framework.

func TestCopy(t *testing.T) { pod := Pod{position: Dot{10280, 2663}, vx: 434, vy: 41, angle: 46, hasShieldOn: false, nextCpID: 2, radius: 400.0} newPod := pod pod.position = Dot{0, 0} if newPod.position.x == pod.position.x || newPod.position.y == pod.position.y { t.Errorf("positions have been changed even if different variables") } 


submitted by /u/Poutrator
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply