Last active
July 19, 2019 03:08
-
-
Save fengyfei/46fe53e3a4ef3eb05cf4402cefabae07 to your computer and use it in GitHub Desktop.
[Go][Reflect] Name of Pointer Type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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