Go Fundamentals
Go is a compiled, strongly typed programming language for building reliable software. It organizes code into packages and includes built-in tools for formatting, testing, dependency management, and concurrency.
itProgramming languages | OpenSkills.info
Intro
Go Fundamentals
Go is a general-purpose programming language with a compact syntax and a focused toolchain. You write source files, group them into packages, and group related packages into a module.
Use this mental model:
module → packages → source files → declarations and statements
↓ ↓ ↓
go.mod import path compiler + Go tools
The language is strongly typed and garbage-collected. It has explicit support for concurrent programming. The standard toolchain builds, formats, tests, documents, and manages dependencies for Go code.
Go is a useful choice when you want a compiled program, direct deployment, clear package boundaries, and concurrency primitives in the language. It does not remove the need to design APIs, synchronize shared state, handle failures, or measure performance.
Start with a module
A module is a collection of related packages released together. Its root contains a go.mod file.
example.com/greeter/
├── go.mod
├── main.go
└── greeting/
├── greeting.go
└── greeting_test.go
The module path is the import-path prefix for its packages. The go command uses it when resolving dependencies.
go mod init example.com/greeter
A package is a collection of source files in one directory that compile together. Every source file begins with a package clause.
package greeting
func Message(name string) string {
return "Hello, " + name
}
An executable program uses package main and defines func main().
package main
import (
"fmt"
"example.com/greeter/greeting"
)
func main() {
fmt.Println(greeting.Message("Ari"))
}
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://go.dev/ref/spec
Supports
- Strong typing, garbage collection, packages, declarations, types, zero values, and control flow
- Arrays, slices, maps, strings, pointers, methods, interfaces, goroutines, channels, and select
- Exact rules behind every quiz answer that cites the language specification
- https://go.dev/doc/tutorial/getting-started
Supports
- Installing Go, creating go.mod, package main, func main, imports, go run, and go mod tidy
- Module paths, external packages, pkg.go.dev discovery, and the introductory reference rationale
- https://go.dev/doc/code
Supports
- Modules, packages, source-file organization, import paths, commands, the go tool, and tests
- The How to Write Go Code reference rationale and module quiz answer
- https://go.dev/doc/tutorial/
Supports
- Official progression through modules, workspaces, databases, APIs, generics, fuzzing, vulnerabilities, and A Tour of Go
- The Tour rationale covering syntax, data structures, methods, interfaces, and concurrency primitives
- https://go.dev/doc/effective_go
Supports
- Formatting, naming, exported identifiers, control flow, defer, methods, interfaces, errors, and concurrency
- The document's own warning about gaps in newer language, module, and library features
- https://go.dev/doc/modules/managing-dependencies
Supports
- Dependency requirements, versions, go get, go mod tidy, and module maintenance
- https://pkg.go.dev/testing
Supports
- Test file and function conventions, testing.T, benchmarks, fuzz targets, and test execution
- https://pkg.go.dev/context
Supports
- Cancellation, deadlines, request-scoped values, API placement, and calling cancellation functions
- The goroutine-lifetime quiz answer
- https://go.dev/doc/faq
Supports
- Interface values that hold typed nil pointers
- Language design boundaries and practical Go behavior
- https://pkg.go.dev/std
Supports
- Maintained standard-library API documentation and examples
- The standard-library reference rationale
- https://github.com/sindresorhus/awesome
Supports
- Discovery of the Awesome Go list under programming languages
- https://github.com/avelino/awesome-go
Supports
- Curated inclusion of GolangCI-Lint as a linters runner
- Curated inclusion of Delve as a Go debugger
- Curated inclusion of GoReleaser as a Go binary delivery tool
- https://golangci-lint.run/docs/
Supports
- Linters, formatters, configuration, and getting-started coverage
- The GolangCI-Lint awesome-link rationale
- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv.md
Supports
- Source-level debugging, execution control, variable evaluation, and goroutine-state inspection
- The Delve awesome-link rationale
- https://www.goreleaser.com/getting-started/quick-start/
Supports
- Release configuration, validation, builds, archives, and publishing
- The GoReleaser awesome-link rationale
