nil is a predeclared identifier representing the zero value for a pointer, channel, func, interface, map, or slice type.
Type must be a pointer, channel, func, interface, map, or slice type
package main
import "fmt"
func main() {
var slic []string
var m map[string]interface{}
var i interface{}
var ptr *int
var c chan string
var f func()
var s *struct{}
fmt.Println(slic,m,i,ptr,c,f,s)
if slic == nil{
fmt.Println("true")
}
if m == nil{
fmt.Println("true")
}
}
//reset
[] map[] <nil> <nil> <nil> <nil> <nil>
true
true
进程 已完成,退出代码为 0