Comments (8)
@syndbg Thank you for your instructions! I'll try your recommendations!
from goenv.
As a newcomer to Go, I fell into the exact situation you outlined above (fresh goenv install, fresh install of 1.7.4, try to install something with go get
and find out my $GOPATH isn't set). So where should I point GOPATH?
from goenv.
@kevbo you can basically do the same thing:
- Install your golang versions with
goenv
- Set
$GOPATH
to the default of~/go
. - Always create repos within your
~/go
path in the normal golang directory structure. - Create a
.go-version
in your repo to specify the golang version to use. - Use
govendor
to install deps to avendor
directory within your repository.- Add the following to your repo's gitignore:
vendor/* !vendor/vendor.json
- New versions of golang will pick this up as of
1.6.0
.1.5.0
will needexport GO15VENDOREXPERIMENT=1
. Older versions will need some love...
- Add the following to your repo's gitignore:
from goenv.
@athrunsun goenv
combined with go-build
(by default it's so) unsets GOPATH
and GOHOME
(ref: https://github.com/syndbg/goenv/blob/master/plugins/go-build/bin/go-build#L964) during install or uninstall (e.g goenv install 1.7.4
, goenv uninstall 1.6
).
After that it does nothing else. So for example if you do:
- Fresh
goenv
install goenv install 1.7.4
goenv global 1.7.4
go get github.com/petar/GoLLRB/llrb
- you'll definitely need to have set$GOPATH
beforehand.
tl;dr You must set $GOPATH
by yourself.
from goenv.
Thanks for your reply, @syndbg !
Here is another question. From my understanding (please correct me if I understand anything wrong):
- python: we cannot install multiple versions of a package using pip, different projects share the same set of packages unless using virtualenv or pyenv.
- ruby: we can have multiple versions of a gem, different projects share the same set of gems unless using rvm or rbenv.
- nodejs: we can install multiple versions of a package using npm, but usually we will have project specific dependencies in a sub folder
node_modules
.
Whose behavior is the closest to golang?
from goenv.
By default Go falls into
python: we cannot install multiple versions of a package using pip, different projects share the same set of packages unless using virtualenv or pyenv.
But I highly recommend using https://github.com/kardianos/govendor or https://github.com/tools/godep to get the best (imo) dependency management behavior that is:
nodejs: we can install multiple versions of a package using npm, but usually we will have project specific dependencies in a sub folder node_modules.
from goenv.
@kevbo $HOME/gocode
is my preference. Note that in Golang 1.8
there's a default $GOPATH
. https://beta.golang.org/doc/go1.8#gopath
from goenv.
@syndbg Thanks for answering that remedial question. Now I have another, more focused on goenv
:
If most Golang projects are checked out/installed to GOPATH
, how do you leverage goenv
to pin a version of Golang to a specific project?
Apologies if that doesn't make sense or if I'm asking the wrong question. I might be looking for too much parity between Golang and Python, which I'm more familiar with. In Python, I use pyenv
to keep multiple versions around. Then I'm able to pin a specific Python version to a project by dropping a .python-version
file into the repo root. Finally, I'd create a virtualenv inside that directory for near-complete isolation for everything else.
from goenv.
Related Issues (20)
- Switching directories doesn't change go version HOT 11
- goenv global and local to use latest Patch Version when unspecified HOT 6
- Add options to remove download progress bar from output HOT 3
- Add support for go1.20.4 (and go1.19.9) HOT 3
- Add support for Go 1.20.5 and Go 1.19.10 HOT 1
- Add support for Go 1.20.6 HOT 4
- Move goenv project to go-nv/goenv? HOT 3
- Write documentation on how to update goenv in AWS CodeBuild Images
- 1.21.0 having install_bsd_arm is causing errors with install_bsd_arm: command not found HOT 8
- PROPOSAL: V3 Collaborative effort? - move to golang-based CLI HOT 2
- Next release? HOT 3
- Add Windows support HOT 2
- If ls or other system utilities are customized, goenv fails HOT 3
- GO_BUILD_MIRROR_URL is not working HOT 2
- Switching Go version when process.env["GOROOT"] is set is unsupported. HOT 4
- immediate release of new Go versions HOT 5
- Go 1.20.14 not available in goenv HOT 3
- Using xxenv-latest for goenv latest --print does not work in 2.2.0 HOT 3
- `goenv global 1.20rc2` fails HOT 6
- `goenv init -` takes much longer time to finish since version 2.2.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goenv.