Skip to content

chore: update Go version, add linting/formatting - #583

Merged
zeroshade merged 1 commit into
mainfrom
lint
Nov 17, 2026
Merged

zeroshade merged 1 commit into
mainfrom
lint

Conversation

@lidavidm

Copy link
Copy Markdown
Member
  • Bump Go version to pick up CVE fixes
  • Enable golangci-lint via pre-commit
  • Accept automatic fixes

Many of the linters are disabled for now because they require more extensive changes to fix.

Closes #582.

@amoeba amoeba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This ended up being a nice tour of how Go has changed over the versions.

I had a question about the setup. It looks like golangci-lint is designed to run either locally or in CI but not easily both. See comment above.

Comment thread .pre-commit-config.yaml Outdated
Comment on lines +35 to +37
- id: golangci-lint
entry: bash -c 'golangci-lint run --fix --timeout 5m'
types_or: [go, go-mod]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a few questions here:

  1. golangci-lint defines types: [go] which I think gets ANDed so does specifying types_or like this work?
  2. I don't think the go.mod linters are enabled by default anyway

I went back and forth a bit to try to figure out something that,

  1. Runs the normal golangci-lint on staged files
  2. Runs on all files in CI

Have you had to do this before? I came up with:

Suggested change
- id: golangci-lint
entry: bash -c 'golangci-lint run --fix --timeout 5m'
types_or: [go, go-mod]
- id: golangci-lint
args: [--timeout=5m]
- id: golangci-lint-full # just for ci
args: [--timeout=5m]
stages: [manual]
  • editing dev.yml to run the manual stage too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is what we do for all our drivers, and it seems to work fine. We already run pre-commit run --all-files so there's no need for golangci-lint-full

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, there's not much point for "run only on staged files", because changes in one file can cause lints in unchanged files.

Comment thread .github/workflows/dev.yml
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: pre-commit run --all-files --color=always --show-diff-on-failure --verbose

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: pre-commit run --all-files --hook-stage manual --color=always --show-diff-on-failure --verbose
env:
SKIP: golangci-lint

@amoeba

amoeba commented Nov 13, 2026

Copy link
Copy Markdown
Member

CI failure looks like a real race or something. I'll see if I can't figure it out.

WORKER SMOKE FAIL: Error: dbc-wasm: failed to lock credentials file: fslock: create c:/users/runneradmin/appdata/local/temp/dbc-wasm-worker-r7a7j7/data/dbc/credentials/credentials.toml.lock.js: open c:/users/runneradmin/appdata/local/temp/dbc-wasm-worker-r7a7j7/data/dbc/credentials/credentials.toml.lock.js: Operation not permitted
    at prefixError (D:\a\dbc\dbc\packages\npm-wasm\index.cjs:31:10)
    at Worker.<anonymous> (D:\a\dbc\dbc\packages\npm-wasm\index.cjs:147:19)
    at Worker.emit (node:events:519:28)
    at MessagePort.<anonymous> (node:internal/worker:270:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:843:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)

@lidavidm
lidavidm marked this pull request as ready for review November 15, 2026 08:13
@lidavidm

Copy link
Copy Markdown
Member Author

CI failure looks like a real race or something. I'll see if I can't figure it out.

WORKER SMOKE FAIL: Error: dbc-wasm: failed to lock credentials file: fslock: create c:/users/runneradmin/appdata/local/temp/dbc-wasm-worker-r7a7j7/data/dbc/credentials/credentials.toml.lock.js: open c:/users/runneradmin/appdata/local/temp/dbc-wasm-worker-r7a7j7/data/dbc/credentials/credentials.toml.lock.js: Operation not permitted
    at prefixError (D:\a\dbc\dbc\packages\npm-wasm\index.cjs:31:10)
    at Worker.<anonymous> (D:\a\dbc\dbc\packages\npm-wasm\index.cjs:147:19)
    at Worker.emit (node:events:519:28)
    at MessagePort.<anonymous> (node:internal/worker:270:53)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:843:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)

It seems to be fixed on re-run.

@lidavidm
lidavidm requested a review from amoeba November 16, 2026 01:07

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. The code changes are mechanical lint fixes, and I checked the ones that rewrite conditions (diagnosticURLEnd, validArchiveSHA256, registryHash): each is a correct De Morgan rewrite.

Pre-commit hook

  1. Use golangci-lint-full instead of the bash -c wrapper. The upstream golangci-lint hook runs golangci-lint run --new-from-rev HEAD --fix, so it only reports new problems. The bash -c entry here replaces that with exactly what the upstream golangci-lint-full hook already does (golangci-lint run --fix, pass_filenames: false). Simpler, and it doesn't need bash:
    - id: golangci-lint-full
      args: [--timeout=5m]
    That lints the whole module on every run, which matches the point that a change in one file can cause lints in others. No manual stage or SKIP is needed, since CI already runs --all-files.
  2. types_or: [go, go-mod] does nothing extra. The upstream hook sets types: [go], and pre-commit combines types and types_or with AND, so a commit that only changes go.mod won't trigger the linter locally. Either drop the line or override with types: [file] plus a files: pattern.

Nits

  1. auth.go: authLoginCompleteMsg(msg) converts one struct type straight into another, which only compiles while the two have identical fields. Adding a field to either one breaks the build somewhere unrelated. authLoginCompleteMsg{cred: msg.cred} was clearer.
  2. The fixes leave var source = httptest.NewServer(...) (and var archive = ...) where := is the normal Go style.
  3. For the govet inline analyzer turned off as "broken in go 1.27", please link the upstream issue so it's clear when it can be turned back on. A tracking issue for turning errcheck, staticcheck and unused back on would also help.

@amoeba amoeba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this as is. I tested that this does what I think it should do locally both with a normal pre-commit hook as well as the --all-files variant we run in CI. Re: @zeroshade's comments, I'm somewhere between indifferent and preferring just to accept what the linter did for those ones.

Thanks for this @lidavidm.

PS: The test failure should is a flake and should be addressed by #586.

Many of the linters are disabled for now because they require more
extensive changes to fix.
@lidavidm

Copy link
Copy Markdown
Member Author

I rebased and made some tweaks; any objections?

@zeroshade
zeroshade merged commit 882ae22 into main Nov 17, 2026
30 checks passed
@zeroshade
zeroshade deleted the lint branch November 17, 2026 16:15
zeroshade added a commit that referenced this pull request Nov 17, 2026
Fixes the failing `Run pre-commit hooks` job on main
(https://github.com/columnar-tech/dbc/actions/runs/44146064069).

#575 merged after #583 enabled golangci-lint with `--fix`, and its CI
ran before that, so the modernizer rewrite of `errors.As` to
`errors.AsType` in `checkDownloadedArchive` was never applied. This is
the hook's own output.

Verified locally: `pre-commit run --all-files` passes, `go build ./...`
and `go test ./cmd/dbc/` pass.

This branch was previously deployed

1 inactive deployment
snapshot — 810c031f Deployed Nov 17, 2026 by lidavidm via snapshot #1292
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.

Set up linting/formatting

3 participants