How to convert a 'string pointer' to a string in Golang?
A simple function that first checks if the string pointer is nil would prevent runtime errors:
func DerefString(s *string) string {
if s != nil {
return *s
}
return ""
}
Dereference the pointer:
strPointerValue := *strPointer