4

Complex Types

Overview

This chapter introduces Go’s more complex types. This will build on what we learned in the previous chapter regarding Go’s core types. These complex types are indispensable when you build more complex software as they allow you to logically group related data together. This ability to group data makes code easier to understand, maintain, and fix.

By the end of this chapter, you will be able to use arrays, slices, and maps to group data together. You will learn to create custom types based on the core types. You will also learn to use structs to create structures composed of named fields of any other types and explain the importance of interface{}.

Technical requirements

For this chapter, you'll require Go version 1.21 ...

Get Go Programming - From Beginner to Professional - Second Edition 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.