如何为var [type struct]
赋值type Mappings []struct {
PropA string
PropB string
}
func main() {
var test Mappings
test = ???
}
提前致谢!
答案 0 :(得分:3)
package main
import (
"fmt"
)
type Mappings []struct {
PropA string
PropB string
}
func main() {
var test Mappings
test = Mappings{
{PropA: "foo", PropB: "bar"},
{PropA: "bar", PropB: "baz"},
}
fmt.Println(test)
}