Hello Guillaume, I haven't had a chance to look at your example closely, but it seems you have two modules defined on your local filesystem, with two go.mod files total.
If that is what you are trying to do, one approach is to use a `replace` directive to let one module know about the on-disk location of the other module. Otherwise, they don't know how to find each other. Also, you usually want to name your modules as if you will publish them someday, which means the `module` line in a go.mod would read something like `module github.com/some/repo`, rather I think you might have something like `module xxx/myLib`, which can be problematic. In general, when importing code with an import statement, you should always use the full import path, which will start with the module path, such as `import "github.com/some/repo/some/pkg"`. You should always use the full import path when importing packages inside the same modules, as well as when importing packages from a different module. You can read more about how to use `replace` to let modules find each other on your local filesystem in these two FAQs on the modules wiki: FAQ: When should I use the `replace` directive? https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive FAQ: Can I work entirely outside of VCS on my local filesystem? https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem Here is a link to a small runnable example that shows two modules side-by-side on the filesystem that use `replace` to make things work. I think that is at least somewhat similar to what you are trying to do, if I followed: https://groups.google.com/d/msg/golang-nuts/1nYoAMFZVVM/eppaRW2rCAAJ Hope that helps at least somewhat. Please don't hesitate to post more questions or comments. Regards, thepudds On Sunday, September 1, 2019 at 6:02:21 AM UTC-4, Guillaume Lescure wrote: > > Hi, > > Thanks for the comments and the ideas :) > > 1. Try 'go build ./...' from the root directory of the module to build >> all the packages in the module. 'go build' without any arguments is the >> same as 'go build .' which means just build the current directory/package. > > > I didn't know the command "go build ./..." and that directly answer my 1st > question, thanks a lot. Now my library is totally built. > Thanks a lot for the tips and the explanation (maybe it sould be > documented ?). > > 2. With only one go.mod, you should not need a 'replace' to find local >> code in your own module. > > > I have 2 go.mod, 1 in myLib folder and 1 other in myBin folder and I > don't want to merge them. > The idea behind that is to simulate 2 repositories, 1 for the library and > 1 for a random application that use that library. > > 3. Make sure you use the full import path in any import statements in >> your code when importing other packages, even when importing other packages >> in the same module. The import path should always start with the module >> path. (The module path what you see on the 'module' line of your go.mod). >> > If that doesn’t help, you might need to share the exact error messages, >> along with the exact go.mod and exact import statements in question. > > > My code is attached. > > Regards, > > >> >> >> (I am on mobile, so sorry this is brief). >> >> Regards, >> thepudds > > -- 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/c27434cd-3ea9-4a29-b38d-6329051228da%40googlegroups.com.