lundi 23 janvier 2023

get pointer to variable stored in reflect.Value in Golang [closed]

Probably this is question is very simple, but i've spent some time and was not able to find any good solution( For example we have the following code:

var someValue int = 10
v := reflect.ValueOf(someValue)
var v1 reflect.Value // should refer to &someValue, but with using of the "v" variable only

I know that the easiest solution will be v1 := reflect.ValueOf(&someValue) or using of reflect.New() function, but unfortunately this will not work in my case.

The "v1" variable should be initialized only with using of the "v" variable.





Aucun commentaire:

Enregistrer un commentaire