docs: rebuild KB in OKF v0.1 with live-verified facts
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.
This commit is contained in:
1 parent
552d1ef8bf
commit
02883d3ed2
116 files changed
+13008
No files matched your search
@@ -0,0 +1,93 @@
|
||||
---
|
||||
type: reference
|
||||
title: Go
|
||||
description: Current best practices for Go projects - modules, project layout, HTTP frameworks, and tooling.
|
||||
tags:
|
||||
- go
|
||||
- golang
|
||||
- bootstrap
|
||||
- engineering
|
||||
timestamp: 2026-08-11
|
||||
verified: 2026-08-28
|
||||
---
|
||||
|
||||
CUT
|
||||
# Go
|
||||
|
||||
This page covers current (2025/2026) best practices for Go projects.
|
||||
|
||||
## Bootstrap
|
||||
|
||||
Initialize a module:
|
||||
|
||||
```bash
|
||||
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 `tool` directives in `go.mod`.
|
||||
* `go run` and `go build` cache executables and embed VCS metadata.
|
||||
* `go test -json` gives 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.
|
||||
|
||||
## Citations
|
||||
|
||||
* [Go modules](https://go.dev/doc/modules)
|
||||
* [Go 1.24 release notes](https://go.dev/doc/go1.24)
|
||||
* [Standard Go Project Layout](https://github.com/golang-standards/project-layout)
|
||||
* [chi](https://github.com/go-chi/chi)
|
||||
|
||||
## See Also
|
||||
|
||||
* [SDLC and Tooling](../sdlc.md)
|
||||
* [Rust](rust.md)
|
||||
* [Docker and Podman](../infra/containers.md)
|
||||
Reference in new issue
Block a user