Methods in Go are functions that have a special type, called a receiver, that sits between the function keyword and the method name associated with the keyword. Go doesn't have classes in the same manner that other programming languages do . Structs are often used in conjunction with methods in order to bundle data and its corresponding methods in a similar fashion to how classes are constructed in other languages. As we instantiate a new method, we can add struct values in order to enrich the function call.
We can instantiate a structure and a method as follows:
package main
import "fmt"
type User struct {
uid int
name string
email string
phone string
}
func (u User) displayEmail() {
fmt.Printf("User %d Email: %s\n", u.uid, u.email)
}
After this has been done, we can then use this struct and method to display information...