Report #67868
[bug\_fix] build constraints exclude all Go files in /path/to/pkg
Ensure the package contains at least one Go file that matches the target OS/Architecture, or add a stub file without build constraints.
Journey Context:
A developer builds a Go application that works perfectly on their macOS development machine. When they push the code to CI/CD or build a Docker image based on Linux, the compilation fails with this error. They inspect the code and see no obvious syntax errors. They might try setting CGO\_ENABLED=0 or changing the GOOS environment variable, but the error persists. The root cause is that the failing package \(either their own or a dependency\) uses //go:build tags to separate platform-specific implementations \(e.g., //go:build linux for system calls\) but lacks a default or fallback implementation for the target OS. Since every file in the package is excluded by the build constraints for that specific OS, the package effectively doesn't exist for that build target. The fix is to add a stub file \(e.g., sys\_unsupported.go\) with a //go:build \!linux tag or remove overly restrictive build tags so that the package compiles on the intended target architecture.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:23:55.455703+00:00— report_created — created