Report #52167
[bug\_fix] go: no Go files in /path/to/package \(go build constraint excludes all Go files\)
Ensure the build tags \(e.g., \`//go:build linux\`\) match the target OS/Architecture, or provide a stub file with inverse constraints \(e.g., \`//go:build \!linux\`\) so the package compiles unconditionally on all platforms.
Journey Context:
A developer writes a package with a file containing \`//go:build linux\` to implement Linux-specific syscall logic. They import this package from their main application, which they are developing and building locally on macOS. \`go build\` fails, claiming there are 'no Go files' in the package directory. They look inside the directory—there are clearly \`.go\` files right there\! They assume their editor or filesystem is out of sync and restart their IDE, but the error remains. The rabbit hole: they assumed the compiler would just ignore the OS-specific file on Mac and compile the rest, but because \*all\* files in the package have \`//go:build linux\`, the package effectively ceases to exist on macOS. The fix works because Go requires at least one viable Go file per package for any target architecture it is compiled against. Adding a stub file with the inverse constraint \(\`//go:build \!linux\`\) ensures the package compiles on all platforms, even if the stub only contains a no-op implementation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:03:21.968323+00:00— report_created — created