Skip to content

Commit 6072836

Browse files
docs(go): add Go standards page and update language matrix
Add content/docs/standards/go.md covering golangci-lint, gofumpt, govulncheck, and go test. Update _index.md with Go column in matrix, target mapping, and per-language list. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fb97fa4 commit 6072836

File tree

2 files changed

+111
-14
lines changed

2 files changed

+111
-14
lines changed

content/docs/standards/_index.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Standards"
33
linkTitle: "Standards"
44
weight: 20
5-
description: "Per-language tooling standards for Python, Bash, Terraform, Ansible, Ruby, and universal security tools."
5+
description: "Per-language tooling standards for Python, Bash, Terraform, Ansible, Ruby, Go, and universal security tools."
66
---
77

88
DevRail defines opinionated tooling standards for each supported language ecosystem. Every tool is pre-installed in the dev-toolchain container and invoked through consistent Makefile targets.
@@ -11,15 +11,15 @@ DevRail defines opinionated tooling standards for each supported language ecosys
1111

1212
The following table shows the default tool for each concern per language. These tools are pre-installed in the `dev-toolchain` container.
1313

14-
| Concern | Python | Bash | Terraform | Ansible | Ruby |
15-
|---|---|---|---|---|---|
16-
| Linter | ruff | shellcheck | tflint | ansible-lint | rubocop, reek |
17-
| Formatter | ruff format | shfmt | terraform fmt | -- | rubocop |
18-
| Security | bandit, semgrep | -- | tfsec, checkov | -- | brakeman, bundler-audit |
19-
| Tests | pytest | bats | terratest | molecule | rspec |
20-
| Type Check | mypy | -- | -- | -- | sorbet |
21-
| Docs | -- | -- | terraform-docs | -- | -- |
22-
| Universal | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks |
14+
| Concern | Python | Bash | Terraform | Ansible | Ruby | Go |
15+
|---|---|---|---|---|---|---|
16+
| Linter | ruff | shellcheck | tflint | ansible-lint | rubocop, reek | golangci-lint |
17+
| Formatter | ruff format | shfmt | terraform fmt | -- | rubocop | gofumpt |
18+
| Security | bandit, semgrep | -- | tfsec, checkov | -- | brakeman, bundler-audit | govulncheck |
19+
| Tests | pytest | bats | terratest | molecule | rspec | go test |
20+
| Type Check | mypy | -- | -- | -- | sorbet | -- |
21+
| Docs | -- | -- | terraform-docs | -- | -- | -- |
22+
| Universal | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks | trivy, gitleaks |
2323

2424
A `--` entry means the concern does not apply to that language. Universal tools run for all projects regardless of declared languages.
2525

@@ -29,10 +29,10 @@ Each Makefile target runs the relevant tools for all languages declared in `.dev
2929

3030
| Target | What It Runs |
3131
|---|---|
32-
| `make lint` | ruff check, shellcheck, tflint, ansible-lint, mypy, rubocop, reek |
33-
| `make format` | ruff format, shfmt, terraform fmt, rubocop |
34-
| `make test` | pytest, bats, terratest, molecule, rspec |
35-
| `make security` | bandit, semgrep, tfsec, checkov, brakeman, bundler-audit |
32+
| `make lint` | ruff check, shellcheck, tflint, ansible-lint, mypy, rubocop, reek, golangci-lint |
33+
| `make format` | ruff format, shfmt, terraform fmt, rubocop, gofumpt |
34+
| `make test` | pytest, bats, terratest, molecule, rspec, go test |
35+
| `make security` | bandit, semgrep, tfsec, checkov, brakeman, bundler-audit, govulncheck |
3636
| `make scan` | trivy, gitleaks (universal -- all projects) |
3737
| `make docs` | terraform-docs |
3838
| `make check` | All of the above in sequence |
@@ -44,6 +44,7 @@ Each Makefile target runs the relevant tools for all languages declared in `.dev
4444
- [Terraform Standards](/docs/standards/terraform/) -- tflint, terraform fmt, tfsec, checkov, terratest, terraform-docs
4545
- [Ansible Standards](/docs/standards/ansible/) -- ansible-lint, molecule
4646
- [Ruby Standards](/docs/standards/ruby/) -- rubocop, brakeman, bundler-audit, rspec, reek, sorbet
47+
- [Go Standards](/docs/standards/go/) -- golangci-lint, gofumpt, govulncheck, go test
4748
- [Universal Security](/docs/standards/universal/) -- trivy, gitleaks
4849

4950
## Consistent Page Structure

content/docs/standards/go.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: "Go"
3+
linkTitle: "Go"
4+
weight: 30
5+
description: "Go tooling standards: golangci-lint, gofumpt, govulncheck, and go test."
6+
---
7+
8+
Go projects use golangci-lint for linting, gofumpt for formatting, govulncheck for security scanning, and go test for testing.
9+
10+
## Tools
11+
12+
| Category | Tool | Purpose |
13+
|---|---|---|
14+
| Linter | golangci-lint v2 | Meta-linter (bundles go vet, staticcheck, gosec, errcheck, etc.) |
15+
| Formatter | gofumpt | Strict superset of gofmt |
16+
| Security | govulncheck | Scans module dependencies for known vulnerabilities |
17+
| Tests | go test | Built-in Go test runner |
18+
19+
All tools are pre-installed in the dev-toolchain container. Do not install them on the host.
20+
21+
## Configuration
22+
23+
### golangci-lint
24+
25+
Config file: `.golangci.yml` at repository root.
26+
27+
```yaml
28+
# .golangci.yml -- DevRail Go lint configuration
29+
version: "2"
30+
31+
linters:
32+
enable:
33+
- errcheck
34+
- govet
35+
- staticcheck
36+
- gosec
37+
- ineffassign
38+
- unused
39+
- gocritic
40+
- gofumpt
41+
- misspell
42+
- revive
43+
44+
issues:
45+
exclude-dirs:
46+
- vendor
47+
- node_modules
48+
```
49+
50+
golangci-lint v2 uses a `version: "2"` key in the config file. It is a meta-linter that bundles dozens of linters. Do not install standalone versions of go vet, staticcheck, gosec, or errcheck.
51+
52+
### gofumpt
53+
54+
No config file required. gofumpt is a strict superset of `gofmt`. It enforces additional formatting rules (grouped imports, consistent spacing). Run with `gofumpt -w .` to apply fixes or `gofumpt -d .` to check.
55+
56+
### govulncheck
57+
58+
No config file required. Scans `go.sum` for known vulnerabilities in module dependencies. Requires the Go SDK at runtime because it uses `go/packages` internally.
59+
60+
## Makefile Targets
61+
62+
| Target | Command | Description |
63+
|---|---|---|
64+
| `make lint` | `golangci-lint run ./...` | Lint all Go files |
65+
| `make format` | `gofumpt -d .` | Check formatting (diff mode) |
66+
| `make security` | `govulncheck ./...` | Dependency vulnerability scanning (if `go.sum` exists) |
67+
| `make test` | `go test ./...` | Run test suite (if `*_test.go` files exist) |
68+
69+
## Pre-Commit Hooks
70+
71+
### Local Hooks (run on every commit, under 30 seconds)
72+
73+
golangci-lint runs on every commit to catch lint and formatting issues:
74+
75+
```yaml
76+
# .pre-commit-config.yaml -- Go hooks
77+
repos:
78+
- repo: https://github.com/golangci/golangci-lint
79+
rev: v2.1.6
80+
hooks:
81+
- id: golangci-lint-full
82+
```
83+
84+
### CI-Only (too slow for local hooks)
85+
86+
- `govulncheck ./...` -- dependency vulnerability scanning
87+
- `go test ./...` -- full test suite
88+
89+
## Notes
90+
91+
- **golangci-lint v2 is the single linting tool.** It bundles go vet, staticcheck, gosec, errcheck, and dozens more. Do not install standalone versions of these linters.
92+
- **gofumpt is a strict superset of gofmt.** All gofmt-valid code is gofumpt-valid, but gofumpt enforces additional style rules. Use gofumpt exclusively.
93+
- **govulncheck requires the Go SDK at runtime.** Unlike other tools that are standalone binaries, govulncheck uses `go/packages` to analyze module dependencies. The Go SDK is included in the dev-toolchain container for this reason.
94+
- **Go tools use `./...` patterns.** The `./...` pattern matches all packages in the module. This is the standard Go convention for recursive operations.
95+
- **`go.sum` presence gates security scanning.** If no `go.sum` file exists, govulncheck is skipped because there are no module dependencies to scan.
96+
- **All tools are pre-installed in the dev-toolchain container.** Do not install them on the host.

0 commit comments

Comments
 (0)