Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Default goroot/gopath ignored by vscode-go #873

Closed
concatime opened this issue Mar 18, 2017 · 10 comments
Closed

Default goroot/gopath ignored by vscode-go #873

concatime opened this issue Mar 18, 2017 · 10 comments

Comments

@concatime
Copy link

concatime commented Mar 18, 2017

Hi.
Cannot find "go" binary. Update PATH or GOROOT appropriately
Set GOPATH environment variable and restart VS Code or set GOPATH in Workspace settings

It seems that this extension does not search for default goroot and gopath in Windows. In fact, by default, the goroot is set to c:/go and %userprofile%/go and this extension should search automatically search for go in c:/go without adding custom goroot or add go to path. Moreover, it should consider that gopath is, by default, and if not overridden by local settings or environment variables, equal to %userprofile%/go .

C:\go\bin>go env

set GOPATH=C:\Users\USERNAME\go
set GOROOT=c:\go

Thank you.

@ramya-rao-a
Copy link
Contributor

Good point.

Fix will be out in the next update.
Thanks for reporting!

@concatime
Copy link
Author

concatime commented Mar 19, 2017

Wow! Thank you for this answer! One point, I don't tell you to define GOROOT or GOPATH, but just let them blank if go is located in C:\go, and there are not in the environment variables.

@ramya-rao-a
Copy link
Contributor

well, I do need to set GOPATH and GOROOT somehwere because all the logic to find the binaries depend on it.

See https://github.com/Microsoft/vscode-go/blob/master/src/goPath.ts

Also the command, Go: Current GOPATH depends on it.

And since process.env['GOPATH'] needs to anyway store the overridden GOPATH, we chose to store the defaults in the same place instead of a separate variables

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Mar 27, 2017

The previous fix depends on go env which cannot be run if the extension doesnt know GOROOT in the first place.

Right fix: 904b267

@ramya-rao-a
Copy link
Contributor

The latest update (0.6.56) to the Go extension has the fix to this issue.

@majimboo
Copy link

I currently have the same issue in Mac.

@ramya-rao-a
Copy link
Contributor

@majimboo Please elaborate. Do you have issues with the goroot to gopath?
Share the below details

  • Have you set any of these settings: go.gopath, go.goroot and go.inferGopath
  • Run echo $GOPATH in the integrated terminal inside VS Code and a separate terminal outside VS Code. Are the results the same?
  • Run go env GOPATH in the integrated terminal inside VS Code and a separate terminal outside VS Code. Are the results the same? Does this match with the earlier results from echo $GOPATH?
  • What is the version of Go you are using?

@waskito
Copy link

waskito commented Nov 16, 2017

Have the same issue in Mac

I didn't set any of go.gopath, go.goroot and go.inferGopath

when I run go env $GOPATH, there is no result at all
but when run go env, I am getting GOPATH="/Users/macintosh/go"

GOROOT="/usr/local/Cellar/go/1.9.2/libexec" because I install go using Homebrew

@concatime
Copy link
Author

Actually, it's go env GOPATH, there is no $.

@concatime
Copy link
Author

concatime commented Nov 16, 2017

And second, you need to define your GOROOT variable inside your shell, or set the go.gopath because your golang directory is not /usr/local/go.

You are a Linux, FreeBSD or OS X user using the the zip or tarball binary downloads from the golang.org website. These binaries have a $GOROOT value of /usr/local/go and recommend you unpack them into that location. If you choose not to do this, then you must set $GOROOT to the location you chose.

Source.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants