March 2020
Intermediate to advanced
406 pages
8h 39m
English
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 mainimport "fmt"type User struct { uid int name string email string phone string}func (u User) displayEmail() { fmt.Printf("User %d Email: %s\n", ...Read now
Unlock full access