Report #457
[bug\_fix] undefined: platformSpecificFunc on target OS
Place the build constraint on the first line of the file using the current syntax \`//go:build linux\` \(or \`//go:build \!windows\`, etc.\), followed by a blank line, then the package clause. For compatibility with Go 1.16 and earlier, keep the legacy \`// \+build\` line in sync directly below the \`//go:build\` line.
Journey Context:
Cross-compiling for Linux from macOS with \`GOOS=linux go build\` fails because symbols defined in \`foo\_linux.go\` are reported as undefined. The file does contain the line \`// \+build linux\`, but it is placed after the package declaration. Older \`// \+build\` constraints had to appear before the package clause and be followed by a blank line. Additionally, the project is built with Go 1.18, where the preferred \`//go:build\` form is recognized. After moving \`//go:build linux\` to the very top of the file, adding a blank line, and keeping the legacy \`// \+build linux\` line for older toolchains, the cross-compilation succeeds and the file is included exactly on the intended OS.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T07:58:19.604156+00:00— report_created — created