Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a GO equivalent to python's virtualenv?

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?

like image 819
will.mendil Avatar asked May 15 '20 06:05

will.mendil


People also ask

Does Go have virtual environments?

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.

Is Pipenv better than virtualenv?

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.

Is virtualenv better than Conda?

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.


1 Answers

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).

like image 108
hobbs Avatar answered Oct 22 '22 06:10

hobbs