Skip to the content ForoHackers
Log inJoin

Go: start here

Go
#3055 · · Quote · Report

Go is a small, statically typed, garbage-collected language built for network services and tools. It compiles fast to a single self-contained binary, and its concurrency is part of the language. Its designers kept it deliberately plain, so most Go code looks alike and a newcomer can read a large project quickly.

Key concepts

  • Goroutines and channels: lightweight concurrent tasks that communicate by passing values.
  • Interfaces: satisfied implicitly by any type that has the methods; small interfaces are the idiom.
  • Errors as values: functions return an error and callers check it; there are no exceptions for ordinary failures.
  • Structs and composition: no inheritance; types are built by embedding and methods.
  • Packages and modules: the unit of code organisation and of dependency management.
  • Tooling in the box: formatter, test runner, documentation and profiler ship with the language.

Vocabulary

  • Slice: a view onto an array with a length and a capacity.
  • Context: a value that carries cancellation and deadlines through a call tree.
  • Defer: runs a call when the surrounding function returns, usually for cleanup.
  • Zero value: the useful default every type has until you set it.

What to study, in order

  1. The official tour and the language specification, which is short enough to read whole.
  2. Write a command-line tool that reads files and prints results, with tests.
  3. Learn slices, maps, structs, methods and interfaces by rewriting a small utility.
  4. Build an HTTP server with the standard library only.
  5. Use goroutines, channels and a wait group for a worker pool; then add cancellation with context.
  6. Run the race detector and the profiler on your own program.

Related tags

#concurrency #backend #http #distributed-systems

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply