addressable value

A value in memory that Go can take the address of with &, such as a variable, a struct field or a slice element.

In more detail

Temporary results, such as a function's return value or a map element, are not addressable. When you call a pointer-receiver method on an addressable variable, Go takes the address for you, so c.Add() works on a Counter variable.

Example

c := Counter{}
c.Add()  // Go passes &c

Related terms

Taught in

References