Skip to content

ci: enforce Go formatting with the pinned toolchain - #612

Draft
houko wants to merge 2 commits into
mainfrom
ci/gofmt-check
Draft

houko wants to merge 2 commits into
mainfrom
ci/gofmt-check

Conversation

@houko

@houko houko commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

CI now runs an independent Go formatting job using the Go version in go.mod. It fails with the filenames of unformatted tracked Go files; NUL-separated Git paths support spaces and leave untracked build output out of the check. The step runs under bash -eo pipefail, so a tracked file gofmt cannot parse fails the job with gofmt's error. A separate style: commit formats the 29 tracked files still unformatted on current main with Go 1.27.3 (the issue listed 33; four were formatted on main since).

Closes #515.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)

Formatting applies to all tracked Go sources, including platform-specific files. The contribution guide explains the check, in English and Chinese.

Screenshots

None; formatting and CI only.

Verification

  • gofmt -l (Go 1.27.3) over every tracked Go file prints nothing.
  • go build ./..., and go tool nsgo check -target all on a Mac; the Linux CI target list also passes on Linux.
  • go tool nsgo test on every package the style commit touches, plus ./cmd/nsgo (its workflow test parses check.yml), ./internal/moduletest and -run 'Layer|Skills|Doc' ..
  • internal/platform/windows tests on Windows 11: the same failures as main in that environment, none in the reformatted tests.
  • The workflow's shell block, run under bash -eo pipefail, rejects an unformatted staged file with a space in its name and lists it; passes once it is formatted, even with an unformatted untracked file present; fails on a tracked file with a syntax error; and passes with no Go files.

Checklist

  • Conventional Commit title; formatting is isolated in its own commit.
  • Contribution guide updated; no user-visible API change requiring a changelog entry.
  • No new dependencies.

@github-actions github-actions Bot added documentation Improvements or additions to documentation macOS Windows Android core base cli ci size/L conflict Conflicts with the base branch; resolve it first labels Nov 17, 2026
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI does not check gofmt, and 33 files on main are not gofmt-clean

1 participant