Saltar al contenido ForoHackers

Go: start here

Go
#549 · Ophuscado · · Denunciar

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

Inicia sesión o únete para responder.