Anonymous structs
suggest changeAn anonymous struct doesn't have a name:
data := struct {
Number int
Text string
}{
42,
"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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents