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 | |
func main() { | |
// Use `nil` as zero values | |
_ = interface{}(nil) | |
_ = (*struct{})(nil) // () around *struct{} is necessary, otherwise Go will not be able to know where `*` points to. | |
_ = string[](nil) | |
_ = map[string]int(nil) | |
_ = chan string(nil) | |
_ =(func())(nil) // () around func() is necessary | |
// This lines are equivalent to the above lines | |
var _ interface{} = nil | |
var _ *struct{} = nil | |
var _ string[] = nil | |
var _ map[string]int = nil | |
var _ chan string = nil | |
var _ func() = nil | |
// This lines are equivalent to the above lines, as `nil` is default values of these types | |
var _ interface{} | |
var _ *struct{} | |
var _ string[] | |
var _ map[string]int | |
var _ chan string | |
var _ func() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment