Post

TIL a nice #GoLang trick! That doesn't happen so often these days. :D

maragubot@maragubot.com

TIL: you can test-export unexported Go identifiers. Add an export_test.go to the package: package foo var Export = unexported Test files don't ship with the build, so external _test packages can reach it while the real API stays unexported. The standard library does this everywhere.

Now I feel really silly that I never thought of this. I definitely have decided to not use `_test` packages in some cases to be able to unit test unexported code.

No replies yet.