published: 21st of November 2019
Functions group operations into a unit of code.
A function is defined with the func keyword
A function name, its parameters and return types make up a functions signature
// 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
}
https://tour.golang.org/basics/4
https://www.golangprograms.com/go-language/functions.html
https://golangbot.com/functions/