Go: cannot find GOROOT directory: C: \ Go; C: \ Go \ Bin

As a name, I just install the Go package on my laptop. OS: Windows 7 Enterpreise SP1 (64 bit) Installation path: C:\go

I set the "Environment Variables":

 GOROOT Value = C:\GO;C:GO\bin 

I made a hello.go file and saved it in C:\go

When I run "go run hello.go" in CMD in C:\ , I get an error message as shown below:

 go:cannot find cannot find GOROOT directory: C:\Go; C:\Go\bin 
+7
go
source share
3 answers

Golang's article " How to write a transition code " mentions:

The GOPATH environment GOPATH indicates the location of your workspace. This is most likely the only environment variable you need to set when developing your Go code.
Please note that this should not be the same path as installing Go.

(and go to install is GOROOT link)

<To get started, create a workspace directory and set GOPATH accordingly.
Your workspace may be located where you like, but we will use $HOME/go in this document.

 mkdir %USERPROFILE%\go set GOPATH=%USERPROFILE%\go 

For convenience, add the bin workspace subdirectory to your PATH :

 set PATH=%PATH%;%GOPATH%\bin 
+3
source share

GOROOT should be installed in d:/programs/go if you installed it there.
GOPATH should be set to d:/workspace/gopath if you want to.
In addition, d:\programs\go\bin should be added to PATH.

It seems that Go only accepts a slash (/), not a backslash (\). But of course, for PATH, this should be a backslash (\).

+3
source share

Do not install GOROOT. Take a look at http://golang.org/doc/articles/go_command.html

+1
source share

All Articles