GO语言如何改变地图指针内对象的值

How can I do it?

I have the list of objects, I want list all and change the name of object. I have the list and I'm doing a while end send to another function, there I change the name, but the name doesn't save.

Any idea how can I do it?

https://play.golang.org/p/el3FtwC-3U

And if there is any book that I can read to learn more, please. Thank for helping me =D

In the range loop:

for _, track := range tracks {
    // send track to channel to change the name
    Working(&track, &c)
}

the track variable is actually a copy of the value contained in the map, because the assignement here works on the Track value type, and in Go, values are copied when assigned.

What you should do instead is use the key of your map and assign the values from within the loop.

for key := range tracks {
    t := tracks[key]
    // send track to channel to change the name
    Working(&t, &c)
    tracks[key] = t
}

See https://play.golang.org/p/9naDP3SfNh

I didn't found how to get pointer to value in map so I think you have to use map[string]*Track instead and then work with pointers to Track structure in your Working function.

See https://play.golang.org/p/2XJTcKn1md

If you are trying modify tracks in parallel you are may be looking for something like this https://play.golang.org/p/1GhST34wId

Note missing buffer in chanel and go Working in for range tracks.