liveBook · Manning

Go

As explained in Go in Action, Second Edition

Go is an open-source, statically typed programming language designed for efficient compilation, execution, concurrency, and software development tooling.

Go is an open-source, statically typed language designed for large codebases and concurrent services. Its design targets five practical costs: slow builds, runtime type mistakes, inefficient execution, difficult concurrency, and fragmented tooling. section 1.1 section 1.0

Those goals shape everyday Go code:

  • Explicit, acyclic package imports and compile-time type checking support a fast edit–build loop while catching type mismatches before execution. section 1.2 section 1.2.2
  • Native compilation, garbage collection, and a single statically linked binary by default simplify execution and deployment; cgo provides a path to existing C libraries. section 1.3
  • Goroutines run concurrent work, channels pass results, and context carries cancellation through request-scoped operations. section 1.4.3
  • Structs, embedding, and implicitly satisfied interfaces favor composition over class hierarchies. section 1.5
  • Formatting, testing, and dependency management come with the Go toolchain. section 2.0
Listing 2.3 Your first main.go file
package main

import "fmt"

func main() {
	// Use hard-coded text to start.
	text := "let's count some words!"

	var numSpaces int

	// Look at the text one byte at a time.
	for i := 0; i < len(text); i++ {
		if text[i] == ' ' {
			numSpaces++
		}
	}

	fmt.Println("Found", numSpaces+1, "words")
}

A complete main.go starts with hard-coded text, counts spaces byte by byte, and prints an initial word-count estimate. Its rough edges make it a starting point rather than a finished replacement for wc. section 2.4.1

As an application grows, named types and structs can make domain data more explicit: a recipe can distinguish measurements and group an ingredient’s quantity and unit. Functions that can fail conventionally return an error as their final value; checking it immediately keeps failure handling beside the operation. section 5.1 section 7.1

An HTTP request

A handler can start goroutines for a database query and a downstream API call, receive their results through channels, and pass along a context so both operations can stop when the client disconnects or a deadline passes. The service can then be deployed as a single binary. section 1.4.3

How Go in Action, Second Edition covers it

How deep it goes
Explains compiler constraints and traces a concurrent HTTP request through goroutines, channels, cancellation, memory reclamation, and deployment.
Examples
Uses a runnable word counter, a recipe domain model, and an HTTP request life cycle.
What it assumes
Introduces the first main.go program with hard-coded input, then develops named types through a concrete domain.
What you can do after
Build it from scratch: create a small Go program and handle function errors explicitly.
How it connects
Connects Go to goroutines, channels, context, composition, structs, and interfaces.

Also explained in

Compare how 11 books explain Go →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Action, Second Edition. The section links point to the parts of the book it draws on.