The reflect package provides the SetMapIndex method for updating elements in a map that are represented by a reflect.Value type, but I don’t see an equivalent for array/slice.
The sample app (link provided below) includes an example of map that’s been made accessible through a a reflect.Value type variable. One of the elements in the map is updated using SetMapIndex. The sample app also includes an example of a slice containing exactly the same data as the map. As far as I can tell, the only way to update an element of the slice through a reflect.Value type variable is to introduce unsafe package Is there a better way that I’m missing that doesn’t require the use of the unsafe package SetMapIndex() equivalent for slice/array <https://play.golang.org/p/X6gsBUW4ME4> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e292b828-4ba9-420d-af2d-8c98fc451ef9n%40googlegroups.com.