Report #104570
[bug\_fix] build constraints exclude all Go files in
Add appropriate build tags to the missing platform files, or move the package to a location that is not platform-specific. Ensure that for each target OS/arch combination, at least one file in the package is not excluded. Common fix: create a stub file without build constraints for unsupported platforms, or use \`//go:build \!excluded\` to include a fallback.
Journey Context:
A developer was cross-compiling a CLI tool for Linux, macOS, and Windows. On the CI server targeting \`linux/arm64\`, the build failed with: \`build constraints exclude all Go files in github.com/user/cli/internal/platform\`. The developer checked the internal/platform directory and saw files like \`prefs\_darwin.go\`, \`prefs\_windows.go\`, and \`prefs\_linux\_amd64.go\` but no file for \`linux/arm64\`. The root cause was that each platform-specific file used a build constraint \(e.g., \`//go:build darwin\`, \`//go:build windows\`, \`//go:build linux && amd64\`\). When building for \`linux/arm64\`, all files were excluded. The environment was a Docker container with Go 1.22 cross-compilation enabled via \`GOOS=linux GOARCH=arm64 go build\`. The developer had to create a new file \`prefs\_linux.go\` with \`//go:build linux\` \(no arch constraint\) that provided a generic implementation for all Linux architectures, or alternatively use an \`//go:build \!darwin && \!windows\` catch-all. The fix was to add a file with a broader build constraint that included the missing architecture.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:06:44.777879+00:00— report_created — created