© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. FreemanPro Gohttps://doi.org/10.1007/978-1-4842-7355-5_8

8. Defining and Using Functions

Adam Freeman1  
(1)
London, UK
 
In this chapter, I describe Go functions, which allow code statements to be grouped together and executed when they are needed. Go functions have some unusual characteristics, the most useful of which is the ability to define multiple results. As I explain, this is an elegant solution to a common issue that functions present. Table 8-1 puts functions in context.
Table 8-1

Putting Functions in Context

Question

Answer

What are they?

Functions are groups of code statements that are executed only when the function is invoked during the flow of execution. ...

Get Pro Go: The Complete Guide to Programming Reliable and Efficient Software Using Golang now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.