Back to all reviewers

go:build directive syntax

golang/go
Based on 2 comments
Go

Ensure go:build directives follow correct syntax with no space between "//" and "go", and use proper logical operators for multiple conditions. Incorrect spacing causes the directive to be ignored by the compiler, potentially including wrong code for target environments.

Configurations Go

Reviewer Prompt

Ensure go:build directives follow correct syntax with no space between “//” and “go”, and use proper logical operators for multiple conditions. Incorrect spacing causes the directive to be ignored by the compiler, potentially including wrong code for target environments.

For multiple platforms, use OR operators (||) between conditions:

//go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || solaris

For complex conditions, use parentheses and logical operators:

//go:build (js && wasm) || windows

Common mistakes include adding spaces (“// go:build”) or using comma-separated lists without operators. Always verify build constraints are properly recognized by checking compilation behavior across target platforms.

2
Comments Analyzed
Go
Primary Language
Configurations
Category

Source Discussions