Let's say we wrote these functions, and we have defined email as before:
type email string func check(a email) { ... } func send(a email, msg string) { ... }
Observe that email is always the first type in the function parameters.
Calling the functions look something like this:
e := "john@smith.com"check(e)send(e, "Hello World")
We may want to make that into a method of the email type. We can do so as follows:
type email string func (e email) check() { ... }func (e email) send(msg string) { ... }
(e email) is called the receiver of the method.
Having defined the methods thus, we may then proceed to call them:
e := "john@smith.com"e.check()e.send("Hello World")
Observe the difference between the functions and methods. check(e) becomes ...