They are explained in detail here - https://anil.cloud/2017/01/26/golang-functions-methods-simplified/
A function in Go follows the syntax:
func FunctionName(Parameters...) ReturnTypes...
Example:
func add(x int, y int) int
To execute:
add(2,3)
A method is like a function, but attached to a type (called as receiver). The official guide states “A method is a function with a special receiver argument”. The receiver appears in between the func keyword and the method name. The syntax of a method is:
func (t ReceiverType) FunctionName(Parameters...) ReturnTypes...
Example:
func (t MyType) add(int x, int y) int
To execute:
type MyType string
t1 := MyType("sample")
t1.add(1,2)
Now lets bring pointers into the table. Go lang is pass by value, means fresh copies of the parameters are passed to each function/method call. To pass them by reference you can use pointers.
Syntax of function with pointer in argument/parameter list.
func FunctionName(*Pointers...,Parameters...) ReturnTypes...
Example
func add(t *MyType, x int, y int) int
To execute:
type MyType string
t1 := MyType("sample")
add(&t1,4,5)
Similarly for methods, the receiver type can be a pointer. Syntax of method with pointer (as receiver)
func (*Pointer) FunctionName(Parameters...) ReturnTypes...
Example
func (t *MyType) add(x int, y int) int
To execute:
type MyType string
t1 := MyType("sample")
t1.add(2,3)
Note that we can still write t1.add() to execute the method with a pointer receiver(even-though ‘t1’ is not a pointer) and Go will interpret it as (&t1).add(). Similarly a method with value receiver can be called using pointer too, Go will interpret p.add() as as (*p).add() in that case (where ‘p’ is a pointer). This is applicable only for methods and not for functions.
Methods with pointer receiver are very useful to get a “Java” like behavior where the method is actually modifying on the value to which the receiver points and not on a copy of it.