Skip to content

Instantly share code, notes, and snippets.

@jim
Created March 27, 2018 17:19
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 jim/26c2d2bf4c405068df4b881e97175d45 to your computer and use it in GitHub Desktop.
Save jim/26c2d2bf4c405068df4b881e97175d45 to your computer and use it in GitHub Desktop.
nil struct fields
package main
import "fmt"
type Bread struct {
name string
}
type Cheese struct {
milk string
}
type Sandwich struct {
bread *Bread
cheese *Cheese
}
func main() {
rye := Bread{name: "Tye"}
sando := Sandwich{
bread: &rye,
}
fmt.Printf("%#v", sando)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment