如何構造具有嵌入式結構的結構文字?構造具有嵌入式結構的結構文字
轉到:
package main
import "fmt"
type Ping struct {
Content struct {
name string
}
}
func main() {
p := Ping{Content{"hello"}}
fmt.Println(p)
}
http://play.golang.org/p/UH4YO6CAFv
這個作品,如果我寫的結構是這樣的:
轉到:
type Ping struct {
Content
}
type Content struct {
name string
}
http://play.golang.org/p/ERGsO4CMEN
如何在第一代碼版本中使用嵌入式結構版本?