匿名结构
可以创建一个匿名结构:
data := struct {
Number int
Text string
} {
42,
"Hello world!",
}
完整示例:
package main
import (
"fmt"
)
func main() {
data := struct {Number int; Text string}{42, "Hello world!"} // anonymous struct
fmt.Printf("%+v\n", data)
}