The question is in the title: Is there a GO equivalent to python's virtualenv? What is the prefered work flow to start a new project?
Now, whatever is installed using go get will be installed in the new isolated virtual go environment. It's GOPATH bin will be already added to the programmer PATH so new applications should be available in the command line after installation.
If you are working with your personal projects and not installing pipenv, I recommend installing pyenv-virtualenv. If you are working in a team or with more than one system, I recommend you to install pipenv which I am covering next.
virtualenv creates project-specific, local environments usually in a . venv/ folder per project. In contrast, conda 's environments are global and saved in one place. PyPI works with both tools through pip , but conda can add additional channels, which can sometimes install faster.
Go modules, which are built into the tooling since Go 1.12 (or 1.11 with a special flag turned on). Create a directory outside of your GOPATH (i.e. basically anywhere), create a go.mod
using go mod init
(which gives your module a declared importpath), and start working. There's no need to "activate" an environment like with venv; the Go 1.12+ tooling will automatically work within the current module when one is detected, e.g. any go get
will happen within module scope.
Although the Go blog entry I linked to mostly focuses on creating a library within a module, which you may want to publish to allow using from elsehwere, this isn't a requirement. You can create a module to hold a program (package main
) as well, and there is no need to publish it (although if you do, it becomes possible to use go get
to install the program).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With