After your initial reply and carefully re-reading I also agree that's what it means. It is however, IMHO, not clear on first reading and there is an implication by omission that "unix" could be considered a valid "GOOS" value. Now I know, I know. The next first-time reader, perhaps not so much.
Peter On Thursday, 31 August 2023 at 11:11:06 UTC+1 Brian Candler wrote: > During a particular build, the following build tags are satisfied: > > - ... > - "unix", if GOOS is a Unix or Unix-like system. > - ... > > > It then says: > > If a file's name, after stripping the extension and a possible _test > suffix, matches any of the following patterns: > *_GOOS *_GOARCH *_GOOS_GOARCH > > (example: source_windows_amd64.go) where GOOS and GOARCH represent any > known operating system and architecture values respectively, then the file > is considered to have an implicit build constraint requiring those terms > (in addition to any explicit constraints in the file). > > This says that only GOOS and GOARCH are considered; it doesn't say that > all possible build tags are interpreted when in the filename, and indeed > there are many that are not. For example, "foo_gccgo.go" and > "foo_go1.12.go" are not treated specially. So I think it's fairly clear > here, as long as you accept that "unix" is neither a GOOS nor a GOARCH. > > Aside: finding a comprehensive list of GOOS and GOARCH values is a bit > tricker. You can run "go tool dist list", or there are third-party > summaries like > https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63 > > On Thursday, 31 August 2023 at 10:44:14 UTC+1 Peter Galbavy wrote: > >> Ah! Got it. Thanks. >> >> Would it perhaps be good to mention this in the docs, here: >> https://pkg.go.dev/cmd/go#hdr-Build_constraints ? >> >> The bullet points refer to "unix" (which is true) and then a naïve >> reader, like me, would think the later paragraphs about GOOS also apply. >> >> Peter >> >> On Thursday, 31 August 2023 at 10:13:12 UTC+1 Brian Candler wrote: >> >>> https://github.com/golang/go/issues/51572 >>> >>> On Thursday, 31 August 2023 at 08:57:15 UTC+1 Peter Galbavy wrote: >>> >>>> I have used comment level build constraints for a while but I moved to >>>> using _linux.go and _windows.go over time as it makes it clearer for >>>> external viewing. >>>> >>>> A user reported they tried to build on MacOS and of course this didn't >>>> work. I renamed the _linux.go files to _unix.go suffixes but then when I >>>> do >>>> "GOOS=windows go build" those files were pulled in too. While I would say >>>> Windows is a POSIX-ish system I would contend it's not UNIX :-) >>>> >>>> I have gone and added "//go:build !windows" to all the renamed files >>>> for now, but is this intended behaviour? >>>> >>>> Peter >>>> >>> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a4c1bbc4-a777-4ce7-b389-949afd7a6a71n%40googlegroups.com.