I am using Go v 1.12 and have created 2 projects (using GoLand but I do not think it matters) using Modules support: ~/temp/A and ~/temp/B. In B project I have a Go file with just one function which I want to call from the A project.
If using Dep (and inside the GOPATH/src folder), I have no problem to import B from A and use the function.
But with modules, what is the correct way to import that B package from project A?
I did a test that project A and B are essential packages in the same (~/temp) folder and modules are working ok, i.e. there is a single .mod file in the root (~/temp) folder. The problem is when A and B have not a common parent folder and thus (as separate projects) have their own .mod file.
To be discoverable, the name of a go-module has to be a schemaless URL, which resolves to a git (or any other supported VCS) repository. Also this of course your code has to be published there.
Also, as far as I read the sparse comments about replace directive, you need to write it without the version, also you should only use two dots to go up a level of folders.
Norbert, a million thank you for your help! From your solution I realised that I had to uncheck the “Vendoring mode support” in GoLand’s project settings (for Go modules support)…Now the project works as expected. Do you have any idea how I can achieve the same but when the projects have their vendor folder present?