Go Notes: Functions
21st November 2019
Functions group operations into a unit of code.
go
// Basic function that accepts no arguments and returns nothing
func stuff() {
// do stuff
}
// Function that accepts an argument
func stuff(s string) {
// do stuff with 's'
}
// Function that accepts arguments and returns a string
func stuffAndThings(s string, t string) string {
return s + t
}
// Function that accepts arguments and returns multiple strings
func stuffAndThings(s string, t string) (string, string) {
// do stuff with s and t.
return s, t
}