匿名結構
可以建立一個匿名結構:
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)
}