Ah, then my fundamental structure was wrong. Since the code didn't contain any tests, I had it in a file named init_mock.go, and it was getting pulled into the binary. So you're saying I should have all test-only code in a file named *_test.go, including code that doesn't contain any tests?
On Monday, January 16, 2017 at 11:39:21 PM UTC-8, Volker Dobler wrote: > > I' unsure if I understand the problem but code in *_test.go is not compiled > into the production binary, so there is no need to extract test code into > its own package: Keeping this in _test.go is probably okay. > > V. > > Am Dienstag, 17. Januar 2017 08:28:34 UTC+1 schrieb alcub...@gmail.com: >> >> I'm trying to test my packages without bloating the size of the binary. >> Currently this consists of moving the test code into a test/ subdirectory. >> If there's a better way to handle this, e.g. tree-shaking, please let me >> know. >> >> Unfortunately, I have a package that needs to be initialized before use >> (mainly connecting to a DB). For testing purposes, I have a mock >> initialization routine. However, that initialization routine needs to >> modify private variables, so I can't move it into test/. Is there any way >> around this that avoids including the mock code in my production binary? >> >> Sincerely, >> >> Alex Becker >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.