Immutability
In this chapter, we will look at immutability. We are going to cover what exactly it means to be immutable, and how the Go language helps preserve immutability at the struct-level. To understand how this works, we will take a look at how Go handles pointers and references to objects, what the performance implications are, and how to decide between the pointer-reference trade-offs. We will also dive into the implications of garbage collection, unit testing, and pure functional programming.
These are the main topics that we will cover in this chapter:
- What is immutability?
- How to write immutable code
- How do pointers and references work in Go?
- Analyzing the performance of mutable and immutable code
- Examples of concurrency and testing with immutable code