Skip to content

fix(deps): patch Go toolchain and x/sys advisories, add lint checks - #15

Merged
looztra merged 6 commits into
mainfrom
chore/golangci-lint-setup
Oct 18, 2026
Merged

looztra merged 6 commits into
mainfrom
chore/golangci-lint-setup

Conversation

@looztra

@looztra looztra commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds static analysis to the repo: golangci-lint (v2 config), govulncheck and deadcode, runnable locally through mise tasks and enforced by a new Lint CI job. It also fixes the findings those tools reported, including vulnerable dependency and toolchain versions.

Changes

Tooling

  • .golangci.yml (v2 schema): the standard linter set plus bodyclose, copyloopvar, errorlint, gocritic, gosec, misspell, nilerr, noctx, prealloc, revive (exported rule), unconvert, unparam, usestdlibvars and wastedassign. Formatters: gofumpt and goimports, with local imports grouped under github.com/looztra/gh-sync.
  • .mise.toml: declares golangci-lint = "2.14" (pinned to a minor so local and CI run the same version), govulncheck and deadcode.
  • New toolbox/mise/tasks/toml/lint.toml with these tasks:
    • lint, lint:fix, vulncheck.
    • deadcode, wrapped so it fails when it finds unreachable functions; deadcode itself always exits 0.
    • check, which runs lint, vulncheck, deadcode and the tests.
  • .github/workflows/code-checks.yml: a new Lint job after Pre-commit that runs the lint, vulncheck and deadcode mise tasks, in parallel with Test.
  • .pre-commit-config.yaml: removes the local gofmt and go-vet hooks. golangci-lint now covers both (gofumpt/goimports and govet).

Lint exclusions

Both are limited to internal/git/git.go. Both linters stay active everywhere else.

  • gosec G204: the binary is always the literal "git", and passing the caller's arguments through is what the wrapper is for.
  • noctx: the internal/git API has no context.Context parameter yet. Adding one to every exported function is a separate refactor.

The comments exclusion preset is deliberately left out because it would silently disable the revive exported rule.

Code fixes

  • parseArgs uses a tagged switch.
  • Tests use errors.Is, and the test helpers use exec.CommandContext(t.Context(), ...).

Dependencies

  • golang.org/x/sys v0.6.0 → v0.44.0 (GO-2026-5024).
  • Go toolchain go1.25.14 → go1.26.9. This fixes 12 stdlib advisories and one os advisory that are only patched in go1.26.9; the go1.25 line no longer receives fixes. Release binaries will now be built with Go 1.26.
  • Minimum Go version (go directive) 1.25.0 → 1.26.0. The module is only built and tested with 1.26, so the declared minimum now matches what is verified. Building from source with a Go 1.25 toolchain and GOTOOLCHAIN=local no longer works.

None of these advisories were reachable from the code, according to govulncheck.

Testing instructions

From a checkout of this branch:

  1. mise install
  2. mise run check: lint, vulncheck, deadcode and tests all pass.
  3. Add func deadProbe() {} to main.go and run mise run deadcode. It exits 1 with deadcode: unreachable functions found. Remove the function.
  4. Add an undocumented exported function such as func ExportedProbe() {} to internal/version/version.go and run mise run lint. revive reports a missing doc comment. Remove the function.
  5. mise run precommit:run: all hooks pass without the gofmt and go-vet hooks.

BEGIN_COMMIT_OVERRIDE
fix(deps): patch Go toolchain and x/sys advisories, add lint checks
END_COMMIT_OVERRIDE

govulncheck reported GO-2026-5024 in golang.org/x/sys v0.6.0 (fixed in v0.44.0) and 13 stdlib advisories in go1.25.14 that are fixed only in go1.26.9; the go1.25 line no longer receives fixes. The go directive stays at 1.25.0.
Use a tagged switch in parseArgs, errors.Is in tests, and exec.CommandContext with t.Context() in test helpers.
Add a v2 .golangci.yml, declare the tools in .mise.toml, add lint, lint:fix, vulncheck, deadcode and check mise tasks, run them in a new Lint CI job, and drop the gofmt/go-vet prek hooks that golangci-lint now covers.
mise runs multi-line tasks with sh, which is dash on Ubuntu runners and rejects 'set -o pipefail'.
The module is built and tested only with the go1.26.9 toolchain, and the go1.25 line no longer receives security fixes, so the 1.25.0 minimum was no longer verified.
@looztra looztra changed the title chore(lint): add golangci-lint, govulncheck and deadcode checks fix(deps): patch Go toolchain and x/sys advisories, add lint checks Oct 18, 2026
- List all 23 revive default rules in .golangci.yml: a custom `rules`
  list enables only the listed rules, so `[exported]` silently dropped
  the rest of revive's defaults.
- Add package doc comments in main.go and internal/git/git.go
  (package-comments rule, previously masked).
- Pin deadcode to major v0 and govulncheck to major v1 in .mise.toml
  instead of "latest": reproducible CI, minor drift via mise go backend.
@looztra
looztra merged commit 1fc4c61 into main Oct 18, 2026
6 checks passed
@looztra
looztra deleted the chore/golangci-lint-setup branch October 18, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant