Reputation: 51
I made a mistake:
go env -w GOROOT=/Users/apple/Documents/testProject/GXB_be:/usr/local/go
I set a wrong path as a variable of go env. This makes it almost impossible for me to use the go env command in the vscode terminal,so I cannot directly use this command to repair it.
% go env
go: cannot find GOROOT directory: /Users/apple/Documents/testProject/GXB_be:/usr/local/go
I refer to this document https://go.dev/doc/install , tried to reinstall go, and tried to restart the vscode terminal, or even the macbook, but it did not work.
I think this is a global problem, because it not only affects vscode, but also occurs on the terminal.
My environment:
go version go1.19.3 darwin/amd64
vscode 1.72.2 (Universal)
Now I have temporarily solved this problem by importing environment variables. However, every time a new vscode terminal is created, the problem still exists.
% go env
go: cannot find GOROOT directory: /Users/apple/Documents/testProject/GXB_be:/usr/local/go
% export GOROOT=/usr/local/go
% go env
warning: GOPATH set to GOROOT (/usr/local/go) has no effect
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
...
How can I restore the environment?
Upvotes: 0
Views: 1245
Reputation: 13
As by @kostix, GOROOT= go env -w GOROOT=/usr/local/go
definitely does.
It also works for Windows platform.
Upvotes: 0
Reputation: 51
Remove (or edit) /Users//Library/Application Support/go/env. -- from Volker
Upvotes: 3