When working with Go modules, what is the idiomatic way to deal with
project-local imports (i.e. directories that are not supposed to be checked
out separately from everything else. A simple example would be something
like this:

project/
    library.go
    example/
        example.go

Here, project is what is supposed to be imported and there will be an
associated go,mod file in the same directory.

example.go is, as the nome implies, just an example and is heavily tied to
the library. It is not supposed to be imported by itself but it uses the
code in library.go.

If in example.go I try doing:

import "project" (where project here is the vcs path for the library)

and then form inside the example directory I do:

go run example.go

It will fail because it will say it can not find "project"

If I add a proper go.mod file in the example directory, then it works but
it actually pulls a version of project from the vcs (this is, of course,
assuming there is already a committed version. otherwise it will also fail)
so if I had made changes locally to library.go, they will not be seem.

So what should I do to satisfy the following requirements:

1 - go run example.go in the example directory works.
2 - Local changes to library.go will be seem when I do 1.
3 - It will still look rigth when everything is commited to vcs (meaning
that if someone check it out somewhere else, 1 and 2 will still work.

Thanks in advance.

-- 
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/CAEd86TzznL8ev7MVBkqEs1gyOmwYWSq7b7AjqWtM7kJMAdFWYw%40mail.gmail.com.

Reply via email to