untitled

tags: learning

content

  • to be continued
// value receiver
func (f File) Read() string { return "..." }
// OK:
Print(File{})   // value has the method
Print(&File{})  // pointer also has it
 
// pointer receiver
func (f *File) Read() string { return "..." }
// OK:
Print(&File{})              // pointer has the method
// NOT OK:
Print(File{}) // compile error: File does not implement Reader (Read method has pointer receiver)

up

down

reference