Reputation: 163
I'm unsure about the imports when it comes to subfolders. My gopath is "/home/username/go" and my project is located in "/home/codeboxx/go/src/project". . Say my project tree looks like this :
- project
- foldera
- foldera.go
- folderb
- folderb.go
- go.mod
- go.sum
- main.go
If in my main.go I import something like "github.com/gorilla/mux", but in my foldera.go I also need this import, how do I do it? Obviously I could just import "github.com/gorilla/mux" again in my foldera.go, but if my module name is like "potato", can't I just do something like "potato/github.com/gorilla/mux" in my foldera.go? I'm wondering because I want everything to be up-to-date with the same versions. Should i just init a go.mod in each subfolders for those? Local packages I don't have trouble doing something like "potato/somepackage" in foldera.go.
I'm probably misunderstanding something, but I've been looking on google and I don't understand it..
Thanks for the help!
Upvotes: 0
Views: 81
Reputation: 64705
They will all use the same version regardless, just because it's in a different folder doesn't mean it will ignore the root go.mod
Upvotes: 1