多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
``` ~~~ package main import ( "fmt" "time" "strconv" ) func (person Person) FmtPerson() { fmt.Println(person.name, person.age, person.sex) } func (person *Person) nextAge() { var age int64 = 1 person.age += age } func (apple Apple) totalPrice() int64 { return apple.quantity * apple.price } func (apple Apple) goodsInfo() string { return "您购买了" + strconv.FormatInt(apple.quantity, 10) + "个" + apple.name + "共计: " + strconv.FormatInt(apple.totalPrice(), 10) + "元" } func (pear Pear) totalPrice() int64 { return pear.quantity * pear.price } func (pear Pear) goodsInfo() string { return "您购买了" + strconv.FormatInt(pear.quantity, 10) + "个" + pear.name + "共计: " + strconv.FormatInt(pear.totalPrice(), 10) + "元" } func formatOrderInfo(goods []Good) int64 { var price int64 for _, item := range goods { price += item.totalPrice() fmt.Println(item.goodsInfo()) } return price } func myInterface(inter interface{}) { fmt.Println(inter) } func myInterfaceList(inter ...interface{}) { for _, item := range inter { fmt.Println(item) } } func mygo(name string) { for i:= 0; i < 10; i++ { fmt.Println(name, i) time.Sleep(10 * time.Millisecond) } } ~~~ ```