xxhash3 icon indicating copy to clipboard operation
xxhash3 copied to clipboard

incorrect-looking // +build lines

Open rsc opened this issue 6 years ago • 0 comments

I've been analyzing // +build usage in the Go ecosystem and turned up internal/cpu/init.go, which says:

// +build 386 !gccgo,amd64 !gccgo,amd64p32 !gccgo

It looks like the intent here was "(386 && !gccgo) || (amd64 && !gccgo) || (amd64p32 && !gccgo)", but the meaning is "386 || (!gccgo && amd64) || (!gccgo && amd64p32) || !gccgo", or equivalently "386 || !gccgo".

There are two ways to write the presumed intent. As one line:

// +build 386,!gccgo amd64,!gccgo amd64p32,!gccgo

or as two lines:

// +build 386 amd64 amd64p32
// +build !gccgo

Best, Russ

rsc avatar Mar 31 '20 20:03 rsc