One improvement here would be if the go compiler rejected unrecognized suffixes, i.e. made _test.go and _unix.go and such a whitelist, and compile errored for unrecognized suffixes, like those with look-alike unicode chars.
As-is, adding new suffixes is arguably a breaking change since they weren’t rejected in the past, i.e. as happened to someone when _ios.go was added as a special build tag.
I think it’s actually kinda unfortunate that go picked _ for the separator here since it’s really common to use it instead of spaces in filenames. Something like ‘foo.windows.go / foo.unix.go / foo.ios.go’ I feel like would have been easier to make a whitelist without getting in the way of people’s file-naming preferences.
One improvement here would be if the go compiler rejected unrecognized suffixes, i.e. made
_test.goand_unix.goand such a whitelist, and compile errored for unrecognized suffixes, like those with look-alike unicode chars.As-is, adding new suffixes is arguably a breaking change since they weren’t rejected in the past, i.e. as happened to someone when
_ios.gowas added as a special build tag.I think it’s actually kinda unfortunate that go picked
_for the separator here since it’s really common to use it instead of spaces in filenames. Something like ‘foo.windows.go / foo.unix.go / foo.ios.go’ I feel like would have been easier to make a whitelist without getting in the way of people’s file-naming preferences.score 10 · canonical