Part 6 · Go basics · Learn to program

Knowledge Videos

Short animated explainers, organised by subject.

Learn to program

8 videos

A step-by-step path for complete beginners: how computers and the web work, then HTML, CSS, JavaScript, Go and a full-stack app of your own.

Part 6 · Go basics

1:38

32What is Go?

Go is a compiled language: the compiler turns main.go into a program and checks it before it runs. go run, go build, and the three parts of a first program.

Gocompilergo rungo buildbeginner
1:26

33Variables and types

In Go every variable has a fixed type: int, float64, string or bool. var and :=, why the compiler rejects the wrong type, and zero values.

Govariabletypeintstringbeginner
1:19

34If, for and switch

Decisions and loops in Go: if and else without brackets, the three shapes of for (counted, condition, forever), and switch, next to the same ideas in Scratch.

Goifforswitchloopbeginner
1:20

35Slices and maps

A slice is a growing list of one type (append, len, range) and a map connects keys to values (delete, and the comma ok check).

Goslicemaprangeappendbeginner
1:17

36Structs and methods

A struct groups named, typed fields into your own type, a method is a function that belongs to a type, and a pointer receiver changes the real value instead of a copy.

Gostructmethodpointertypebeginner
1:16

37Errors in Go

A function that can fail returns an error as a second value. nil means success, and you check it with if err != nil, instead of an error jumping out like in JavaScript.

Goerrornilstrconvbeginner
1:18

38Testing in Go

A test is a small program that checks your code. _test.go files, Test functions, go test with PASS and FAIL, and table tests with many cases.

Gotestgo testtable testdebuggingbeginner
1:21

39Packages and modules

A package is a folder of Go files, a module is the whole project (go mod init, go.mod), how import works, and why a capital letter makes a name visible.

Gopackagemoduleimportgo modbeginner