In the instant example where you have the name in the code, just include the name as a string: fmt.Printf("Type: %T, Name:%#+v\n", myVariable, "myVariable")
But in the general case where that pointer value has been passed to a function or stored in a map or slice and you are referencing it only from the map or slice, I do not think you can, at all, because the pointer is NOT pointing at the variable. Rather, the variable and the pointer are referencing the same in-memory object, and that object has no name. Consider this tweak to your example: https://go.dev/play/p/aX7MfsnuZPZ What name would either of these return? All of these variables in the end point to the same place - if before all the myVariableX= lines there was a Val := "Swiss Cheese" myVariable = &Val , every one of those variables would point to the string "Swiss Cheese", and would have the same pointer value. What then, should the name of that pointer be? >From the computer's perspective, it is not a sensical question. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/adea855d-b9dc-4e51-a45e-11d413f5a791n%40googlegroups.com.