Search⌘ K

Methods Versus Functions

Explore the distinctions between methods and functions in Go. Understand how methods are associated with receiver types, how to invoke them correctly, and how they can modify receiver state using pointers. This lesson prepares you to effectively implement behaviors on struct types in Go programming.

Differences between a function and a method

A function has the variable as a parameter:

Function1(recv)

A method is called on the variable:

recv.Method1()

A method can change the values (or the state) of the receiver variable provided this is ...