Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

go

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
like image 811
littlebaggio Avatar asked Feb 20 '14 05:02

littlebaggio


2 Answers

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 (\).

like image 198
ruben2020 Avatar answered Nov 06 '22 19:11

ruben2020


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
like image 40
VonC Avatar answered Nov 06 '22 19:11

VonC