“method requires pointer receiver” in Go Programming Language

后端 未结 2 1199
情书的邮戳
情书的邮戳 2021-02-02 13:56

I just saw a presentation of the Go programming language and thought I\'d try to write a few lines. Everything worked fine until I tried to use an interface in this situation. H

2条回答
  •  广开言路
    2021-02-02 14:26

    Change it to: doSomething(&e). func (e *entity) inc() satisfies incer interface only for *entity type. There is no inc() for just entity type and that's what's you're passing to doSomething().

提交回复
热议问题