Go Struct Constructors
package main/*from www .j a va 2 s.co m*/ import "fmt" type Language struct { Name string Age int } func (e *Language) Init(name string, age int) { e.Name = name e.Age = age } func info(name string, age int) *Language { e := new(Language) e.Name = name e.Age = age return e } func main() { lang := new(Language) lang.Init("Java",25) fmt.Printf("%s: %d\n", lang.Name, lang.Age) langInfo := info("CSS",5) fmt.Printf("%v",langInfo) }