Go is an open-source, statically typed, compiled language designed for practical systems programming. It is particularly suited to services and system-level processes built by teams working on large codebases. Its compiled programs include a runtime with garbage collection, trading some low-level control for simpler memory management. section 1.1 section 1.3 section 1.3.1
Go is also a development toolchain. The `go` command supports compilation, module-based dependencies, tests, formatting, and documentation. Packages group code and are imported by name; standard-library packages such as `fmt` and `net/http` provide common application building blocks. section 1.1 section 1.2.4
Run a small HTTP service
Initialize a project with `go mod init hellogo`, then save this as `main.go`: package main import ( "fmt" "net/http" ) func hello(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello, world!") } func main() { http.HandleFunc("/", hello) http.ListenAndServe("localhost:4000", nil) } Use `go run main.go` while developing, or `go build main.go` to create an executable. The `main` package supplies the entry point; `net/http` registers a handler and serves requests. section 1.5
Other Go techniques become useful as an application grows:
- Use `go test` to exercise functions and `go test -cover` to check statement coverage. A string-reversal test demonstrates why processing text as bytes can fail where processing it as runes succeeds. section 1.2.4
- Use structs, methods, and interfaces to connect types by the behavior they provide rather than by class inheritance. section 3.2
- Handle ordinary failures as errors; reserve panics for severe abnormal conditions. Goroutines support concurrent execution, including concurrent web-server connections. section 4.0 section 1.3.4
Go is not the first choice for resource-constrained embedded systems: its runtime and garbage collector have a cost. For server deployment, a compiled Go binary contains the application, imported packages, and runtime, avoiding a separately installed language runtime. section 1.3 section 1.3.3










