- Hands-On System Programming with Go
- Alex Guerrieri
- 236字
- 2021-06-24 13:42:24
Summary
In this chapter, we looked at some of the history of Go and its current pros and cons. After understanding the namespace by looking at how the package system and imports work, we explored its type system with basic, composite, and user-defined types.
We focused on variables by looking at how they can be declared and initialized, which operations are allowed between types, how to cast variables to other types, and how to see what the underlying type of interface is. We saw how scope and shadowing work and the difference between constants and variables. After this, we jumped into functions, a first-class type, and how each signature represents a different type. We then understood how methods are basically functions in disguise and attached to a type that allows custom types to satisfy interfaces.
In addition, we learned how to control the application flow using statements like if, for, and switch. We analyzed the differences between the various control statements and the looping statement and viewed what each built-in function does. Then, we saw how basic concurrency works with channels and goroutines. Finally, we got some notion of how Go's internal memory allocation works, some history and performance of its garbage collector, and how to build, install, and run Go binaries.
In the next chapter, we are going to see how to put some of this into practice by interacting with the filesystem.