Chapter 2
The language
Go taught against the JavaScript you already know.
By the end of this chapter you'll be able to
- What actually pushed you here
- The shape of Go, in one page
- What you give up, stated plainly
- The one example that explains everything
- What this book does
Lessons
Module: The language
Why Go, when you already ship JavaScript
You already build and ship software.
Installing Go and your first program
This chapter gets Go on your machine, gets a program running, and introduces the toolchain.
Variables, types, and the compiler that argues with you
This is the chapter where Go feels most foreign, and it is worth knowing why in advance.
Functions, multiple returns, and the end of try/catch
This is the chapter that decides whether you get on with Go.
Structs and methods, against objects and classes
A JavaScript object is a bag of keys you can add to at any time.
Slices: the array that is not an array
Go has arrays and it has slices.
Maps, and why iteration order is random on purpose
A Go map is a hash table with typed keys and typed values.
Pointers, without the fear
Pointers have a reputation they do not deserve, earned in languages where you can do arithmetic on them and walk off the end of memory.
Packages, modules and imports, against npm and ESM
You have been writing single-file programs.
Chapter assignment
Finish every assignment in The language
Each lesson in this part ends with its own assignment, named for the leaderboard. Finish them in order.
See success criteriaLesson 1 takes ~15 min.
Start chapterSpot a typo? Have an idea?
Help us improve this chapter. One click opens a GitHub issue with this chapter's URL pre-filled — suggest a clearer wording, report a bug, or request a new lesson. The course keeps improving thanks to learners like you.
Suggest an improvement on GitHub