Report #518
[bug\_fix] go build: undefined: setNonblock or build constraints exclude all Go files in ...
Provide a fallback implementation file with the complementary build constraint \(for example, pair a file with //go:build linux with another file with //go:build \!linux\). Verify that tags match the target GOOS/GOARCH, use go build -tags mytag when custom tags are required, and run go vet and tests on the platforms you support.
Journey Context:
A package compiled fine on Linux but failed on macOS with 'undefined: setNonblock'. The file that defined the function started with //go:build linux, so the macOS build simply skipped it and no other file provided the symbol. Adding a new file named sys\_bsd.go with //go:build darwin && implementing the same function with kqueue-based non-blocking logic fixed macOS while keeping Linux untouched. The root cause is that build constraints tell the go command which files to include for a given target; if a required symbol is only defined behind an unsatisfied tag, the linker sees an undefined identifier.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T08:58:30.286115+00:00— report_created — created