Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-19 Thread Henry
Thanks. It does work. I suppose I had wrong assumptions on how the 'internal' package works. I thought it is usable only by its immediate parent package. It turns out it is usable by any other packages that share the same parent as the internal package. Thanks again, everyone! :) Henry On

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Marian Kopriva
What Dave suggested should work, in your example package1, package2, package3 and package4 should be able to import testhelpers with `import "project/internal/testhelpers"` On Sunday, December 18, 2016 at 2:48:41 PM UTC+1, Henry wrote: > > Where do you put this internal package in relation to

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Henry
The problem with putting my test utilities under a single file, lets say util_test.go, is that the utilities are not usable across different packages within the same project. As far as I know, you cannot import test packages (eg. mypackage_test). -- You received this message because you are

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Mark Mandel
Any reason not to have a `utils_test.go` file - and puts your utilities in there? Seems like the simplest solution. Then they only get included for your tests. Using /internal for testing tools feels a bit strange to me IMHO. Mark On 18 December 2016 at 11:13, Matt Harden

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Matt Harden
An import of a path containing the element “internal” is disallowed if the importing code is outside the tree rooted at the parent of the “internal” directory. Note the use of the word "tree" in that sentence, as opposed to "directory". On Sun, Dec 18, 2016 at 5:48 AM Henry

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Henry
Where do you put this internal package in relation to the rest of the packages? Is it something like this: project/ package1/ package2/ package3/package4/ internal/testhelpers/ I thought internal package would only be visible to its immediate parent? I want it to be usable across

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Dave Cheney
Like Nigel suggested project/ internal/ testhelper On Sunday, 18 December 2016 21:45:25 UTC+11, Henry wrote: > > No. I meant something like this: > > project/ > -- package1 > -- package2 > -- package3 > > Now there is a reusable test utility that is used by the tests in > package1,

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Henry
No. I meant something like this: project/ -- package1 -- package2 -- package3 Now there is a reusable test utility that is used by the tests in package1, package2, and package3. So the question is where do I put the test utility without exposing them as a part of the project's API? I don't

Re: [go-nuts] Packaging Test Utilities in a Project

2016-12-18 Thread Nigel Tao
On Sun, Dec 18, 2016 at 1:51 PM, Henry wrote: > I have reusable test utilities in a project. They are used by various > packages in the project for testing purposes, and at the same time I don't > want to expose these utilities as public APIs. Since it is impossible to

[go-nuts] Packaging Test Utilities in a Project

2016-12-17 Thread Henry
Hi, I have reusable test utilities in a project. They are used by various packages in the project for testing purposes, and at the same time I don't want to expose these utilities as public APIs. Since it is impossible to import another test package in Go, I wonder what would be the best way