What is the difference between parameter and receiver

前端 未结 2 960
南方客
南方客 2020-12-16 12:56

I am following a Go tutorial and am stuck as I cant understand a particular method signature:

func (p *Page) save() error {
    filename := p.Title + \".txt\         


        
2条回答
  •  隐瞒了意图╮
    2020-12-16 13:42

    The receiver is the object on what you declare your method.

    When want to add a method to an object, you use this syntax.

    ex: http://play.golang.org/p/5n-N_Ov6Xz

提交回复
热议问题