3 ms·
Info about workspace is outdated. Go modules allows you to to work outside GOPATH
by Strum355 7y ago
Info about workspace is outdated. Go modules allows you to to work outside GOPATH
- milap 7y agoAgree. With go mod we workspace can be outside of GOPATH. The post does not cover go mod.
- hliyan 7y agoI recently hastily put together a "Learn Go in 10 days" program for my team, where I only used go modules: https://github.com/hliyan/learn-golang/blob/master/day-08/main.go https://github.com/hliyan/learn-golang/blob/master/day-08/ma... Feedback welcome.
- itwy 7y agoThanks so much for sharing. Very helpful to me.
- ausjke 7y agoagree, newbie to golang, just started with go1.13beta1 which will make go-module preferred to GOPATH/workspace.
- sascha_sl 7y agoThe default mode is already `auto`, which checks if you're within GOPATH (if GOPATH is set) and defaults to mod if you're not.
- ausjke 7y agodon't know this, thanks! I also assume you no longer need set GO111MODULE=on anymore
- cyphar 7y agoThat depends -- it defaults to "auto" which means that its enabled outside of $GOPATH but disabled inside it. If you're working on a project that makes use of "go mod vendor" and is built from within your $GOPATH (which is true of quite a few free software Go projects) then you'll need it.
- geoka9 7y agoSome useful tools[0] are still to catch up with Go modules, so using GOPATH still makes sense if you use them. [0] https://github.com/golang/go/issues/24661 https://github.com/golang/go/issues/24661