Report #7851
[bug\_fix] build constraints exclude all Go files in /path/to/package
Ensure the target environment matches the build tags, or add a default implementation file without build constraints. If the tags require CGO, explicitly set \`CGO\_ENABLED=1\` during the build.
Journey Context:
A developer is cross-compiling a Go application for Linux using \`GOOS=linux go build\`. The build fails, claiming all Go files are excluded. They check the package and see \`sock\_linux.go\` \(with \`//go:build linux\`\) and \`sock\_windows.go\` \(with \`//go:build windows\`\). Confused, they verify they are building for Linux. Digging deeper into the source, they notice \`sock\_linux.go\` actually has the constraint \`//go:build linux && cgo\`. The developer is unaware that cross-compiling disables CGO by default \(\`CGO\_ENABLED=0\`\). Because the \`cgo\` constraint fails, \`sock\_linux.go\` is excluded, leaving zero files for the Linux build. The fix is either to set \`CGO\_ENABLED=1\` if the C interop is truly needed, or remove the \`cgo\` constraint if it was accidental. This works because the Go build system evaluates all \`//go:build\` constraints strictly against the target environment variables before compiling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T03:51:55.887629+00:00— report_created — created