Receiver

Noun · Development

Definitions

  1. In Go, the typed parameter before a method name (func (r *MyType) DoSomething()) that binds the method to that type, analogous to 'this' or 'self' in other languages. Value receivers operate on a copy; pointer receivers operate on the original. In channel-based concurrency, a receiver is the reading end of a channel that consumes sent values.

    In plain English: The object a method belongs to in Go — it's how Go attaches functions to types without traditional classes.

    Example: "Use a pointer receiver on the SetName method, otherwise you're mutating a copy and the original struct never changes."

Related Terms