Essential Go Structs  Edit on GitHub      File Issue

Anonymous structs

You can create anonymous structs:

data := struct {
	Number int
	Text   string
}{
	42,
	"Hello world!",
}

fmt.Printf("data: %+v\n", data)
data: {Number:42 Text:Hello world!}

Anonymous structs are often used in test suites.

  ↑ ↓ to navigate     ↵ to select     Esc to close