what is invalid receiver type in Go
tags: learning go programming
content
- example of invalid receiver type:
type MyStruct struct {
value int
}
type MyStructAlias = MyStruct
func (s MyStructAlias) doSomething() { // ...do something }
func (i int) doSomething() { // ...do something }- these two functions won’t work:
- alias can NOT be function receiver
- primitive type (pre-defined type) can NOT be function receiver