Hacker News new | ask | show | jobs
by ttz 287 days ago
You can also include

package main

files in a non-main package directory (usually sed when implementing go generate)

1 comments

What people usually do is add a build tag to the file(s) with package main, so they're not compiled on a regular compile/test run. But you can't combine them as such (and you can do this with any package name – there's nothing special about the main package here).
Yep - my point was that _test is not the only exception to the "rule"
No, there is no exception for the "main" package. It's just build tag trickery. You can do this with any package names (although it doesn't make much sense to do so).
Ah, I see what you're objecting to. Yes, it is build tag trickery, and wouldn't work without it