You can use the Index method on reflect.Value if it is an integer- indexable type.
https://play.golang.org/p/07YXRPBMqo6 On Mon, 2019-07-01 at 12:45 -0700, Mark Bauermeister wrote: > I have the following code, where the TokenMap struct is actually part > of another package. > idMap is not exported and thus not accessible without reflection. > > Through reflection I can easily find the value of "int", which is > "28". > Now, I'd like to do the opposite though. I'd like to find "28"'s > index (i e "int"). > > How would I go about that? > > https://play.golang.org/p/UnMi4gQGrIr > -- > 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/844522f8-145c-44c1-b382-338c2936d5fb%40googlegroups.com > . > For more options, visit https://groups.google.com/d/optout. -- 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/ec35272bd8c1f91c6b10619ae537995e56411ddc.camel%40kortschak.io. For more options, visit https://groups.google.com/d/optout.