When defining a method in Go, which convention is followed for the receiver parameter?

  • It is commonly a single letter that represents the type, like 't' for type
  • It must always be named 'receiver'
  • It must be a pointer to the type
  • It must be of interface type
In Go, the convention for the receiver parameter in a method definition is to use a single letter that represents the type, often the first letter of the type's name. This parameter can be either a value or a pointer type, depending on whether the method needs to mutate the receiver.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *