Skip to content

Instantly share code, notes, and snippets.

@extremecoders-re
Last active April 13, 2024 18:43
Show Gist options
  • Save extremecoders-re/9e8e515aed82d95c205df45dffa8f5fd to your computer and use it in GitHub Desktop.
Save extremecoders-re/9e8e515aed82d95c205df45dffa8f5fd to your computer and use it in GitHub Desktop.
Using VSCode with a conda go environment
$ conda create -n goenv go
$ conda activate goenv
(goenv) $ conda install -c conda-forge gxx_linux-64  # Required for the vscode go extension

Note the current goroot path

(goenv) $ go env GOROOT
/home/ec/miniconda3/envs/go/go

Add the path to vscode settings.json (Workspace or Global)

For workspace: config is saved in .vscode/settings.json

{
    "go.goroot": "/home/ec/miniconda3/envs/go/go",
}

Next install the Go plugin for VScode. It will prompt to install a few tools. Click on "Install All". However the installation of some tool will surely fail which needs to be installed manually like.

(goenv) $ go install -v github.com/cweill/gotests/gotests@v1.6.0
(goenv) $ go install -v github.com/haya14busa/goplay/cmd/goplay@v1.0.0
(goenv) $ go install -v github.com/go-delve/delve/cmd/dlv@latest
(goenv) $ go install -v honnef.co/go/tools/cmd/staticcheck@latest
(goenv) $ go install -v golang.org/x/tools/gopls@latest

The exact tools which failed and the corresponding command to install them can be found in the Output panel in VScode.

References

@extremecoders-re
Copy link
Author

On windows with conda installed from scoop

{
    "go.goroot": "C:/Users/Administrator/scoop/apps/miniconda3/current/envs/go1.22",
    "terminal.integrated.env.windows": {
        "GOROOT": "C:/Users/Administrator/scoop/apps/miniconda3/current/envs/go1.22"
    },
}

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment