Suppose I am writing a package that is in its own module, and I want
to test it. Not with unit tests, but with a larger program that uses
other non-standard packages as well.

Before modules, I would develop the package in ~/go/src, write the
test program somewhere else, and import the package. This doesn't work
with modules.

What does work is move the test program into a subdirectory of the
package, add that directory to .gitignore . This works, as long as the
test program doesn't need any non-standard packages that the package I
am writing needs.

When the test program needs more non-standard packages, I need to add
these to go.mod of the package I am developing, even though that
package itself doesn't need it.

When I give the directory with the test program its own go.mod then it
can't use the files in the parent directory as the imported package.

I turned it the other way around. I put the package I am writing in a
subdirectory of the test program. That works, as long as that subdirectory
doesn't have its own go.mod .

So, in one setup, I end up with a package with a go.mod with too many
dependencies. An in the other I end up with a package without a go.mod .

How do I get this right?

Is there a way to tell go.mod that it should use local files instead
of a repository, just for the development phase?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5390153a-0c05-436e-888f-9ab911d75bf8n%40googlegroups.com.

Reply via email to