Skip to content

Instantly share code, notes, and snippets.

@fengyfei
Last active July 19, 2019 03:08
Show Gist options
  • Save fengyfei/46fe53e3a4ef3eb05cf4402cefabae07 to your computer and use it in GitHub Desktop.
Save fengyfei/46fe53e3a4ef3eb05cf4402cefabae07 to your computer and use it in GitHub Desktop.
[Go][Reflect] Name of Pointer Type
package main
import (
"fmt"
"reflect"
)
type Pod struct {
Name string
}
func main() {
pod := &Pod{Name: "kube-proxy"}
t := reflect.TypeOf(pod)
if t.Kind() != reflect.Ptr {
panic("Ptr required")
}
fmt.Println("Kind is: ", t.Elem().Name())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment