Summary
We have 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. Functions in Go serve many purposes, including enhancing the usage and readability of code. We learned how to create and call functions. We studied the various types of functions used in Go and discussed scenarios where each of the function types can be used. We also expounded 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. We also discussed various parameters and return types and studied defer
.
In the next chapter, we shall be exploring errors and error types and learning how to build custom errors, thus building a recovery mechanism to handle errors in Go.