dimanche 6 novembre 2016

How to get a new variable of the same type of another variable with Golang

How can I do this? I want a function to be able to return me the same type as it got it from one of its argument. I need something like the below:

type Whatever struct {
    Title string
}

hey:= Whatever{Title:"YAY"}
thetype := reflect.ValueOf(hey).Kind()

// This does not work
BB:= new(thetype)





Aucun commentaire:

Enregistrer un commentaire