Functions
Explore how to create and utilize functions in Go, focusing on the func keyword, independent function design, multiple return values, and the use of anonymous functions with closures to write clear and effective code.
We'll cover the following...
The main elements of packages are functions, which are the subject of this lesson.
Tip: Functions must be as independent of each other as possible and must do one job (and only one job) well.
So, if we find ourselves writing functions that do multiple things, we might want to consider replacing them with multiple functions instead.
The func keyword
We should already know that all function definitions begin with the func keyword, followed by the function’s signature and its implementation and that functions accept zero or more arguments and return zero or more values back. The single most popular Go function is main(), which is used in every ...