I am trying to establish an architecture with go as suggested here (others are quite similiar): https://github.com/golang-standards/project-layout
So I have
my_project_folder/cmd/app/main.go and I run my application from the main folder with
go run cmd/app. So far so good.
Now I want to break my code in several pieces for internal usage, so I create:
my_project_folder/internal/pkg/libonecontaining several go - files, all of them are declared to be in
- Equivalently I also create
my_project_folder/internal/pkg/libtwoalso containing some go - files and declared as
So I end up with the following architecture / structure (excerpt):
The question is how would I import my two libraries in my
One working option is to use relative paths (
../..). But I already read that this is bad practice in the go-universe. Another, the better, option would be to use “remote paths”, right?
So even though I do not use github, I try to change the import in my main.go to:
But this crashes… Is this because I have no mods.go file? Or do I still have to set my GOPATH? (I thought this is not needed anymore?)
Is there an explicit documentation on how remote paths are resolved? And how can I avoid that if somebody enters git get no unwanted repository from github is pulled because I just used a fake name?
Thanks in advance and Sorry for the big confusion… I would not have asked If I were successful in searching