直接上代码:
-
-
-
-
-
-
-
-
-
-
fmt.Println("=====>:\t", num)
-
fmt.Println("=====>:\t", *num)
-
运行结果:
-
-
-
-
Process finished with exit code 0
下面的形式是不可以的:
-
-
-
-
-
-
-
-
fmt.Println("=====>:\t", num)
-
fmt.Println("=====>:\t", *num)
-
运行结果:
-
panic: runtime error: invalid memory address or nil pointer dereference
-
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x48b4ea]
-
-
-
-
E:/Program/go2/goPath/src/xingej-go/xingej-go/xingej-go666/string/test.go:7 +0x2a
-
-
Process finished with exit code 2
原因? 可能是取不到常量5的地址
转载于:https://blog.51cto.com/xingej/2117313
|
请发表评论