More context would be useful; i.e., what are you really trying to do and why? Such information often allows people to provide better answers; including whether this is an example of the [XY Problem]( https://xyproblem.info/) or you have a misunderstanding how slices work. Given your play.golang.org reproducer neither of those responsies seem likely but nonetheless...
On Fri, Jun 4, 2021 at 8:29 PM Deiter <hwaterf...@gmail.com> wrote: > 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 > <https://groups.google.com/d/msgid/golang-nuts/e292b828-4ba9-420d-af2d-8c98fc451ef9n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- 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/CABx2%3DD8LzCuVKpN6rb%2BBDFqFumCS%3Dys8uCLd0r6ykk82cpc7%3DQ%40mail.gmail.com.