An anonymous struct is a Go struct type declared inline, without a named type identifier. It is especially useful in table-driven tests, where each case needs only a small set of fields. section 5.1.2 section 5.6
Table-driven test cases
Replace a separately declared testCase type:\n\n type testCase struct {\n input string\n want []rune\n }\n testCases := map[string]testCase\n\nwith an inline anonymous struct:\n\n testCases := map[string]struct {\n input string\n want []rune\n }{\n "5 characters in english": {\n input: "HELLO",\n want: []rune("HELLO"),\n },\n "5 characters in japanese": {\n input: "こんにちは",\n want: []rune("こんにちは"),\n },\n }\n\nThe map key names each test, while the anonymous struct holds the fields required by that case. A named structure remains valid when reuse or a clearer type name is valuable. section 5.1.2 section 5.6
