關(guān)于golang的構(gòu)造函數(shù)的寫法來源于Rob Pike他老人家2014年寫的一篇博客:[https://commandcenter.blogspot.hk/2014/01/self-referential-functions-and-design.html],同時他也是golang語言的發(fā)明者之一。下面通過一個自己的小例子說明這種寫法。同時也列出很多開源的golang項目中使用這種寫法。
Example
type Person {
name string,
age int64,
country string,
...
}
func NewPerson(name string,age int64,country sting)*Person{
return &Person{ name: name,
}