Go is a small language, but one with a few differences to many common languages. For example, Go supports an OO-style of development, but doesn't have classes, and it has built-in primitives to simplify concurrent programming.
The content in this book is aimed at introducing these concepts to someone new to Go (but not new to programming in general). The content is split in to the following sections:
- Introduction: built-in types, variable declaration, function and custom types.
- Object-oriented development
- Concurrency
Each section explains the relevant concepts, walks through a number of examples and code samples, and ends with an exercise to put the concepts in to practice.
Although you need have no real experience with Go itself, this is not a "learning to code" guide. Specifically, you are expected to have practical experience with the principles behind object-oriented software development (in any language).
There are templates available for each of the exercises. If you've cloned this
repository under your $GOPATH
then you can just edit and run the template
file in place. Alternatively, follow the link to the template already set up
in the Go Playground, and work from there instead.
- The Basics: source / playground
- Object Orientation
- Methods: source / playground
- Interfaces: source / playground
- Embedding: source / playground
- Concurrency
- Goroutines: source / playground
- Channels: source / playground
Example solutions are also available, but don't look at those until you've had a go yourself!
This guide can be used as an individual study-aid, but it was designed to be presented as a hands-on workshop. In this format, the workshop should take around four hours, with each section talked through by the presenter, before the participants work through the relevant exercise (preferably in pairs). An accompanying slide deck is available on Speaker Deck.
The source for this material is available on GitHub. Please raise any issues there, and contributions (fixing typos, better formatting, improvements to code examples etc) are more than welcome.
The gopher image on the cover is by Renee French. The buffered and unbuffered channel images are from Ardan Labs.
Except where otherwise noted, the content of this repository is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.