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
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 (\).
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 yourPATH
:
set PATH=%PATH%;%GOPATH%\bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With