I am wondering what code will be compiled into the go binary if you compile a binary using go build ./...
. This will compile a binary that has a cli program. For this cli program, I have test code and non test code. I currently have several flavours of test code:
foo_test.go
in packagefoo_test
foo_internal_test.go
in packagefoo
testutil.go
in packagetestutil
that provides test utility functions
No test code is actually referenced in the non test code. The testutil functions are only imported in the test files.
If the test code is infact compiled into the binary , how much of a problem is this?
*_test.go
files, so they're not just eliminated during linking, they're never compiled at all.*_test.go
files are only included by thego test
command, in the named package. They are never even seen by the compiler otherwise.go build ./...
, that is building all the packages included in the wildcard, then discarding all the compiled objects.