Skip to content

Instantly share code, notes, and snippets.

@ydnar
Created July 17, 2023 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ydnar/d2c849b2ff9d931feff3437b94472ea0 to your computer and use it in GitHub Desktop.
Save ydnar/d2c849b2ff9d931feff3437b94472ea0 to your computer and use it in GitHub Desktop.
nil as untyped zero value for Go
package main
func main() {
var s string
var _ = s == nil // true
var i int
var _ = i == nil // true
var v struct {
time.Time
}
var _ = v == nil // true
var _ = v.Time == nil // true
var a [4]uint8
var _ = a == nil // true
var b []uint8
var _ = b == nil // true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment