Go by Example: Methods

    https://gobyexample.com/methods

    package main
    import "fmt"
    type rect struct {
        width, height int
    }
    
    func (r *rect) area() int {
        return r.width * r.height
    }
    
    func (r rect) perim() int {
        return 2*r.width + 2*r.height
    }
    
    func main() {
        r := rect{width: 10, height: 5}
        fmt.Println("area: ", r.area())
        fmt.Println("perim:", r.perim())
        rp := &r
        fmt.Println("area: ", rp.area())
        fmt.Println("perim:", rp.perim())
    }

    实在不明白area和perim有什么区别(加没加星号)
    既然没有private、public关键字,那就意味着,大写包外可用,小写包外不可用?

    validate