一个包中的私有属性 要用小写字母
package inital
import "fmt"
type Order struct{
userId string
Amount int
}
//
func (this *Order) Read()string{
fmt.Println(this.userId)
return this.userId
}
func (this *Order) SetUserId(userId string){
this.userId=userId
}
测试:
func TestAdd(t *testing.T){
order:=inital.Order{Amount: 15}
order.SetUserId("15")
fmt.Println(order)
order.Read()
fmt.Println("this.userId=",order.Read())
}