I just followed the steps to convert my project to a using modules with go mod init and go mod tidy and now I get these not found errors. Details as follows:
It’s never simple to migrate non-module to module, I’m afraid. You do to sort this out for each mis-aligned dependencies.
You’re looking for replace directive and redirect all your myProject to local dependency pathing. The is caused by your import statement. Assuming that myProject is your project root repository, the clause should be something like:
replace (
"myproject" => ./
)
General Practice
When using go.mod, you use import using the public pathing + replace clause, as in:
Then in go.mod, replace your remote source with local directory, as in:
replace (
"github.com/<name>/<project>" => ./
)
That way, go module will look into local directory first before pulling a remote version. On user side, it is aligned with effective Go and never gets confused with import statement.
Ideally yes. However, if you are doing local devlopement (e.g. adding feature), you gonna need the local direcotry clause to prevent the compiler from keep pulling from remote every time you run a test or build instead of against your local code changes.
I do not know why this is not built in but I hope in near future.