How to dereference a pointer in Go?

In Go language, is there a way to convert *string to string ? (or, for that matter, any *T to T ?)

I looked on the Internet and through some Go documentation, but I can not find it - maybe I missed it.

+6
source share
1 answer

To turn a *T into T , use the * operator:

 func Dereference(strptr *string) string { return *strptr } 

I highly recommend that you read about pointers before moving on to the language. They are a fundamental concept, without which it is impossible to effectively use the language.

+5
source

All Articles