package playne

imports "programmer"

Golang – struct, make and the case of the missing variable

I made a rookie mistake last night. I forgot an asterisk in my code and it caused me a an hour of confusion!

TL;DR – methods on structs in golang need their stuct passed as a pointer if you want to modify it!

This works

func (f *Foo)SomeFunc() {}

This does not!

func (f Foo)SomeFunc() {}

Posted

in

by