Scratch notes
Rules in the Go spec that define what methods, for a particular type, get bound to the value of that type:
-
value types, require value semantics (value receivers)
- only those methods implemented with value semantics are attached to values
-
pointer types, allow pointer or value semantics (value or pointer receivers)
- all methods defined using pointer semantics or value semantics
- the full method set of behavior is attached to pointers or addresses
Relevant to method sets for implementing interfaces.
Values of type user do not implement the interface because pointer receivers don't belong to the method set of a value.
References
Scratch notes
Rules in the Go spec that define what methods, for a particular type, get bound to the value of that type:
value types, require value semantics (value receivers)
pointer types, allow pointer or value semantics (value or pointer receivers)
Relevant to method sets for implementing interfaces.
Values of type user do not implement the interface because pointer receivers don't belong to the method set of a value.
References
https://www.youtube.com/watch?v=Z5cvLOrWlLM
https://github.com/ardanlabs/gotraining/blob/master/topics/go/language/interfaces/example3/example3.go
https://play.golang.org/p/w981JSUcVZ2