littlebaggio
littlebaggio

Reputation: 89

go: cannot find GOROOT directory: C:\Go; C:\Go\bin

As title, I just install Go package in my laptop. OS:Windows 7 Enterpreise SP1 (64bit) Install path: C:\go

I've set "Environment Variables":

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

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

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

go:cannot find cannot find GOROOT directory: C:\Go; C:\Go\bin

Upvotes: 8

Views: 22150

Answers (4)

STEEL
STEEL

Reputation: 10107

you will need to add (Edit the system environment variables) GOPATH & GOROOT as below. (Windows 10) And then restart the system

enter image description here

Upvotes: -2

ruben2020
ruben2020

Reputation: 1549

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

It seems like Go only accepts slash (/) and not backslash (\). But of course, for PATH, it should be backslash (\).

Upvotes: 3

VonC
VonC

Reputation: 1330012

The Golang article "How to Write Go Code" does mention:

The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code.
Note that this must not be the same path as your Go installation.

(and go installation is reference by GOROOT)

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

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

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

set PATH=%PATH%;%GOPATH%\bin

Upvotes: 2

Volker
Volker

Reputation: 42486

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

Upvotes: 1

Related Questions