Anonymous structs

suggest change

An anonymous struct doesn't have a name:

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

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

As a result you can only create values of anonymous struct where point of struct definition.

Anonymous structs are often used in unit tests.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents