Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to combine Goenv to use VSCode? #293

Open
tabris233 opened this issue Mar 22, 2023 · 6 comments
Open

How to combine Goenv to use VSCode? #293

tabris233 opened this issue Mar 22, 2023 · 6 comments

Comments

@tabris233
Copy link

tabris233 commented Mar 22, 2023

Does anyone use both vscode and goenv?

Because of different projects use different Golang versions. So I look for Golang Version Management tool. I found goenv, it's cool. Goenv can install different Goalng versions and switch easily like pyenv. Very thanks for this tool.

I use VSCode to write the golang code. Although I have set goenv local 1.18.10, VSCode still recognizes the Golang version of goenv global. Like this.

image

So how to change to 1.18.10?

(Very sorry for my poor english)

@saheljalal
Copy link

Ran into the same issue as well. Any guidance on how to fix this since it prepends to the path causing goenv to be useless in this case. Thanks in advance.

@waset
Copy link

waset commented May 16, 2023

me too ...
looking forward to someone to help solve it.

@amyangfei
Copy link

One possible way is to add the following line(replace the path with real $GOROOT) to tell vscode the path of go root, to either the ~/Library/Application Support/Code/User/settings.json (default for current user) or /Users/yangfei/work/code/vitess/.vscode/settings.json (will override user configuration and project only)

  "go.goroot": "/Users/yangfei/work/tools/goenv/versions/1.19.9"
echo $GOROOT
/Users/yangfei/work/tools/goenv/versions/1.19.9

For example

Screen Shot 2023-06-04 at 13 52 38

@brianstrauch
Copy link

The above solution is not ideal since settings.json will have to be updated whenever the go version is updated.

@serdardalgic
Copy link

When I'm in a directory that defines a .go-version, I open vscode or vscodium as follows from this directory:

# For vscode
$> code .
# For vscodium
$> codium .

This allows the IDE to inherit the environment values from this directory.
Make sure that you already closed any vscode instances before opening the IDE from this directory.

I think changing the goroot values manually within vscode is not a maintainable solution when you're working with multiple projects with different go env values.

@clearyup
Copy link

@tabris233 @waset https://github.com/owenthereal/goup, use this bro,
image
the config is this,
image
image
when you use goup change go verison,reload vscode, the goversion in the status bar will automatically switch
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants