4. Functions — A Book of Go
2 min readMay 14, 2024
Functions are a way to write reusable code.
The absolute basics of functions in Go:
- Can hold 0 or more arguments
- Type is provided after the name of the parameter:
func add(x int, y int)
- A type for the return value must be provided
- If a function is not returning anything (void), leave out the return type