嵌套式结构体

构建结构体时如果其中有字段的类型同样为结构体,需要将其与常规字段隔开。

//bad usage
type Client struct {
  version int
  http.Client
}

//good usage
type Client struct {
  http.Client

  version int
}

Last updated

Was this helpful?