Setting a struct from inside a nested func doesn't work.
I've already tried the examples from the documentation: https://play.golang.org/p/Pw9f20zwja
type myStruct struct {
abrakadabra bool
}
func (f *ChangeMe) SetName(abrakadabra bool) {
f.abrakadabra = true
}
func something() {
var flag ChangeMe
f := new(ChangeMe)
copy := func(r io.ReadCloser, w io.WriteCloser) {
//...some code..
if err != nil {
f.SetName(true)
log.Println(flag.abrakadabra)
}
}
in the log print - the abrakadabra boolean remains false (starter value), why doesn't it change to true?