Functions and Methods in Go?
The term "method" came up with object-oriented programming. In an OOP language (like C++ for example) you can define a "class" which encapsulates data and functions which belong together. Those functions inside a class are called "methods" and you need an instance of that class to call such a method.
Ref: https://stackoverflow.com/a/8263702
------
There are two ways of defining them. If you want to modify the receiver use a pointer like:
If you dont need to modify the receiver you can define the receiver as a value like:
Last updated