1 Commits
Author SHA1 Message Date
sneak 8fb3f0c9b5 Install pinned goimports in script/bootstrap (closes #184)
Check / check (pull_request) Skipped
script/fmt runs gofmt, goimports, and npx prettier, but bootstrap
installed only git, make, go, and golangci-lint, so `make fmt` failed
with `goimports: not found` on a fresh machine. bootstrap's contract is
to install all dependencies idempotently.

Add ensure_goimports: it skips when goimports is already on PATH,
otherwise `go install`s golang.org/x/tools/cmd/goimports at a pinned
exact version (v0.49.0; integrity via the Go module checksum database)
and places the binary in /usr/local/bin so it is on PATH regardless of
shell config, mirroring the golangci-lint release install. v0.49.0
requires Go 1.25, matching go.mod; v0.50.0 would force a Go 1.26
toolchain download.

Model: opus-4-8
2026-09-22 08:03:07 +00:00
2 changed files with 23 additions and 1 deletions
+3
View File
@@ -22,6 +22,9 @@ main cannot regress.
- 2026-09-22: Added `.prettierignore` so `make fmt` no longer rewrites
the vendored `static/js/alpine.min.js` bundle (#185).
- 2026-09-22: `script/bootstrap` now installs a pinned `goimports`
(`golang.org/x/tools` v0.49.0) into `/usr/local/bin`, so `make fmt`
succeeds on a fresh machine after `make bootstrap` (#184).
- 2026-09-09: Fixed four deployability blockers found by QA: CSRF origin
check over plain HTTP (`UPAAS_PLAINTEXT_HTTP`, #189), pulling the git
image when absent (#190), the env-var editor CSRF token lookup (#191),
+20 -1
View File
@@ -5,7 +5,9 @@
# or apk (detected in that order); assumes NOTHING is present (not git,
# make, or go). golangci-lint is packaged in nix, brew, and apk; on apt
# it is installed from a hash-verified GitHub release archive (never
# curl | sh).
# curl | sh). goimports is installed with `go install` at a pinned
# version (integrity via the Go module checksum database) into
# /usr/local/bin so it is on PATH.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
@@ -15,6 +17,9 @@ GOLANGCI_LINT_VERSION="2.12.2"
# sha256 of golangci-lint-2.12.2-linux-<arch>.tar.gz release archives
GOLANGCI_LINT_SHA256_AMD64="8df580d2670fed8fa984aac0507099af8df275e665215f5c7a2ae3943893a553"
GOLANGCI_LINT_SHA256_ARM64="44cd40a8c76c86755375adfeea52cfd3533cb43d7bd647771e0ae065e166df3a"
# golang.org/x/tools goimports, 2026-08-13. v0.49.0 requires Go 1.25 (matches
# go.mod); v0.50.0 needs Go 1.26. Integrity via the Go module checksum database.
GOIMPORTS_VERSION="v0.49.0"
PKGMGR=""
SUDO=""
@@ -102,6 +107,19 @@ ensure_golangci_lint() {
esac
}
# goimports is not packaged uniformly across nix/apt/brew/apk, so install it
# with `go install` at a pinned version and place the binary in /usr/local/bin
# so it is on PATH regardless of shell config, as the golangci-lint release
# install does. Requires go, which main installs first.
ensure_goimports() {
if ! missing goimports; then return 0; fi
detect_pkgmgr
tmp="$(mktemp -d)"
GOBIN="$tmp" go install "golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION}"
$SUDO install -m 0755 "$tmp/goimports" /usr/local/bin/goimports
rm -rf "$tmp"
}
main() {
cd "$ROOT"
@@ -112,6 +130,7 @@ main() {
# Go toolchain and linter
if missing go; then pkg_install go golang go go; fi
ensure_golangci_lint
ensure_goimports
go mod download