Home / Code typing practice / Go
Go Typing Practice
Free Go typing practice: type real Go with :=, if err != nil, range loops, channels and goroutines. Build speed on the patterns Go developers type every day.
Go is deliberately simple, so the same patterns come up again and again: short declarations with :=, if err != nil, for range loops and channel sends with <-. Practising them makes everyday Go noticeably faster to write.
The snippets cover functions, error wrapping with fmt.Errorf, Printf verbs, structs, channels and goroutines, the code of Go web services and command-line tools.
Go code you will type
Each session picks from these, in random order. Line breaks are shown as single spaces.
func add(a, b int) int { return a + b }
if err != nil { return fmt.Errorf("read config: %w", err) }
for i, v := range values { fmt.Printf("%d: %v\n", i, v) }
type Server struct { Addr string; Port int }
ch := make(chan string, 10); go func() { ch <- "done" }()
Symbols to watch
:=!=<-{ }%( )",Not sure which finger to use? See the programming symbols finger chart.
Tips for typing Go faster
- Type if err != nil { as a single phrase; you will type it thousands of times.
- The channel arrow <- is Shift and comma, then minus: right middle finger, then right little finger.
- Go needs no semicolons, so let your right little finger rest instead of reaching out of habit.
Frequently asked questions
Is Go easy to type?
Yes: few symbols and no semicolons. The parts worth practising are :=, if err != nil and <-.
Does gofmt make typing speed less important?
gofmt fixes spacing, not typos. You still type every identifier, brace and operator yourself.