工厂模式 写法
type test struct{
Name string
age int
}
等同于构造函数的 工厂模式 用于其他包创建构造体
func Method(name string) *test{ \返回一个test
return &test{
Name:name,
}
}
func (p *test) SetAge(age int) //写入封装的age数据就使用构造体方法完成
{
p.age = age
}
fuc (p *test) GetAge() int {//读数据age用方法来return回数据
return p.age
}