I am using go module, the file structure is like this:
~/some_path/goapp/go.mod
~/some_path/goapp/go.sum
~/some_path/goapp/main.go
~/go/src/fakedomain.com/fakeuser/foo/foo.go
Inside main.go
, I tried to do
import fakedomain.com/fakeuser/foo
But, it doesn't work at all. I tried to add the following to go.mod:
require fakedomain.com/fakeuser/foo
OR
require fakedomain.com/fakeuser/foo
replace fakedomain.com/fakeuser/foo /home/user/go/src/fakedomain.com/fakeuser/foo
None of them works. How can I achieve this?
Edited
This question is about how to import a local package inside ~/go/src/ from a module which is outside ~/go/src/.
In other words, the module which is outside ~/go/src/ will import a local package inside ~/go/src/. I thought I could import it directly (that is what I did in the old days without module), but I was wrong. It turns out that I have to make the local package inside ~/go/src/ become a module too.