Created
October 12, 2017 11:03
-
-
Save 7c00/ca4c0d37e889868572e9362d4f6697de to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
"os" | |
"reflect" | |
) | |
func main() { | |
if len(os.Args) >= 2 && os.Args[1] == "-p" { | |
// with -p | |
t := reflect.TypeOf((*error)(nil)).Elem() | |
fmt.Println(t.Kind()) | |
return | |
} | |
t := reflect.TypeOf((error)(nil)) | |
fmt.Println(t.Kind()) | |
} |
This file contains hidden or 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
$ go run niltype.go | |
panic: runtime error: invalid memory address or nil pointer dereference | |
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x47b7d7] | |
goroutine 1 [running]: | |
main.main() | |
...(omitted).../niltype.go:18 +0x177 | |
exit status 2 | |
$ go run niltype.go -p | |
interface |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment