Copy of the legacy ~/.pi/agent/docs tree rebuilt as the command-center knowledge base: concept files promoted to path identity, index listings stripped of frontmatter, all wikilinks/relative links resolved, every checkable claim verified against the live fleet (Dankserver = Ryzen 7 7700X + RTX 3090; Strix Halo is Dankclaw), unverifiable claims tagged. kb-lint exits 0.
2.4 KiB
2.4 KiB
type, title, description, tags, timestamp, verified
| type | title | description | tags | timestamp | verified | ||||
|---|---|---|---|---|---|---|---|---|---|
| reference | Go | Current best practices for Go projects - modules, project layout, HTTP frameworks, and tooling. |
|
2026-08-11 | 2026-08-28 |
CUT
Go
This page covers current (2025/2026) best practices for Go projects.
Bootstrap
Initialize a module:
go mod init my-module
Then write a main.go with package main.
Project Layout
Follow the Standard Go Project Layout:
my-project/
├── cmd/ # Application entrypoints
├── internal/ # Private application code
├── pkg/ # Public library code
├── api/ # Protobuf or OpenAPI definitions
├── deploy/ # Dockerfiles and Helm charts
├── scripts/ # Build and CI scripts
├── go.mod
└── go.sum
Use internal/ for code that must stay private to the module.
Tooling
| Category | Tool | Notes |
|---|---|---|
| Module manager | go modules | Built into the toolchain. |
| Formatter | gofmt | Built in. |
| Linter | golangci-lint | The standard CI aggregator. |
| Testing | go test ./... |
Use table-driven tests. |
| Static analysis | staticcheck | Use with golangci-lint. |
HTTP Frameworks
| Framework | Best For | Notes |
|---|---|---|
Standard net/http |
Most Go projects | Idiomatic, no dependencies. |
| chi v5 | REST APIs | Minimalist, stdlib-compatible. |
| gin | High-throughput APIs | Fast, JSON binding. |
| echo | Full-featured APIs | Middleware and validation. |
Use the standard library or chi for most projects.
Notable 2025/2026 Changes
- Go 1.24 added generic type aliases and
tooldirectives ingo.mod. go runandgo buildcache executables and embed VCS metadata.go test -jsongives structured output for CI.
Related Technologies
- pgx for PostgreSQL.
- slog for structured logging.
- cobra for command-line interfaces.
- gRPC with
google.golang.org/grpc. - testcontainers-go for integration tests.