Makefile+workflows: fallback to `GOPATH/bin` on non-existent `GOBIN`
What changed, and why it matters
This commit is a build-system maintenance change. It makes the Makefile fall back to GOPATH/bin when the GOBIN environment variable is not set, and explicitly sets GOBIN in the GitHub Actions workflow. This prevents build tools like the linter from being looked for in a non-existent directory. There is no security vulnerability here.
No security action needed. Treat as normal build hygiene.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The Makefile previously used go env GOBIN directly to locate golangci-lint and goimports. If GOBIN was unset, GO_BIN became empty, producing paths like /golangci-lint. The patch adds a fallback to $(go env GOPATH)/bin and sets GOBIN explicitly in CI. This is a robustness improvement for the development/build toolchain, not a code change affecting runtime behavior, cryptography, networking, or consensus.
Changed components
Makefile.github/workflows/main.ymlInspect captured patch +8 / −1
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 50b4185..2a98f59 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -5,6 +5,7 @@ env:
# go needs absolute directories, using the $HOME variable doesn't work here.
GOCACHE: /home/runner/work/go/pkg/build
GOPATH: /home/runner/work/go
+ GOBIN: /home/runner/work/go/bin
GO_VERSION: 1.22.11
jobs:
diff --git a/Makefile b/Makefile
index ef8459a..4ccc503 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,12 @@ LINT_PKG := github.com/golangci/golangci-lint/v2/cmd/golangci-lint
GOIMPORTS_PKG := golang.org/x/tools/cmd/goimports
GO_BIN := ${shell go env GOBIN}
+
+# If GOBIN is not set, default to GOPATH/bin.
+ifeq ($(GO_BIN),)
+GO_BIN := $(shell go env GOPATH)/bin
+endif
+
LINT_BIN := $(GO_BIN)/golangci-lint
GOIMPORTS_BIN := $(GO_BIN)/goimports
@@ -73,7 +79,7 @@ install:
$(GOINSTALL) $(PKG)/cmd/findcheckpoint
$(GOINSTALL) $(PKG)/cmd/addblock
-#? release-install: Install btcd and btcctl release binaries, place them in $GOPATH/bin
+#? release-install: Install btcd and btcctl release binaries, place them in $GOBIN
release-install:
@$(call print, "Installing btcd and btcctl release binaries")
env CGO_ENABLED=0 $(GOINSTALL) -trimpath -ldflags="-s -w -buildid=" $(PKG)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.