Summary
In this chapter, we studied why and how functions are an essential part of the Go programming language. We also discussed various features of functions in Go that make Go stand apart from other programming languages. Go has features that allow us to solve a lot of real-world problems and do so in a small, iterable, and manageable way. Functions in Go serve many purposes, including enhancing the usage and readability of code.
Next, we learned how to create and call functions. We studied the various types of functions that are used in Go and discussed scenarios where each of the function types can be used. We also expounded on the concept of closures. Closures are essentially a type of anonymous function that can use variables declared at the same level as that at which the anonymous function was declared. Then, we discussed various parameters and return types and studied defer
. We also discussed how to keep your code clean and separated such that similar logic can be packaged...