samedi 28 décembre 2019

How can you dynamically resolve or introspect variables in golang?

Is there a way to resolve or introspect a random variable in golang? For instance, if I have a string value strVal := "s" that corresponds to the name of a var s string in the same scope, can I dynamically look up the value of s? I know if these are fields of a struct, I can use reflection, but for my use case, I am dealing with locally scoped variables.





Aucun commentaire:

Enregistrer un commentaire