Go - Alias

Table of Contents

About

Aliasing also occurs when:

  • we take the address of a variable or copy a pointer, we create new aliases or ways to identify the same variable. For example, *p is an alias for v.
  • we copy values of reference types like slices, maps, and channels, and even structs, arrays, and interfaces that contain these types.

Aliasing is useful because it allows us to access a variable without using its name, but this is a double-edged sword: to find all the statements that access a variable, we have to know all its aliases.


Powered by ComboStrap