Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I guarantee you it is even worse with preprocessor spaghetti, than build tools.


I think we're talking past each other.

Build constraints with "//go:build" already exist, I'm not making them up or proposing something new: https://pkg.go.dev/go/build#hdr-Build_Constraints

This has nothing to do with preprocessor spaghetti, which is impossible in Go. Either a file is included or it is excluded. Neither with file naming nor "//go:build" can you cause only portions of a file to be compiled.

Really, the _tag.go mechanism is just a very simple kind of build constraint, equivalent to "//go:build tag". The problem is that it relies on a magic list of known build tags, and the contents of that list change over time. Apart from _test.go, which is a little too convenient to give up in my opinion, the rest of the tags could be pushed into build constraints, or at the very least, the list of known build tags could be frozen in its current state.


Build contraints are the version of Go's preprocessor spaghetti, when those conditions get so complex, that one needs pen and paper to understand what is actually included.


Well, then it ought to go the other way. If you create foo_bar.go and bar is not a known build tag, you should get a compiler error.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: