Installing Go

704 views
Skip to first unread message

Skip Cave

unread,
Jul 7, 2015, 9:08:21 PM7/7/15
to golan...@googlegroups.com
I installed Go on my Windows 8.1 machine using the go1.4.2.windows-amd64.msi file. That created a directory in the root - C:\Go. Then I tried to run Go by opening a command window and typing C:\Go\bin\go.exe   No luck. A command window pops up briefly, and then go away before I can read it. How do you start GO?

Justin Israel

unread,
Jul 7, 2015, 9:44:53 PM7/7/15
to Skip Cave, golan...@googlegroups.com
When you say you want to "start GO", what do you want to do? Build something? Check the installed version? 
Have you set your Path envto include C:\Go\bin?

This looks like an easy to follow getting started guy for windows users, if you are finding the golang.org windows instructions lacking: 

If your Path is set up properly, typing the following should work:   go version

On Wed, Jul 8, 2015 at 1:08 PM Skip Cave <sk...@caveconsulting.com> wrote:
I installed Go on my Windows 8.1 machine using the go1.4.2.windows-amd64.msi file. That created a directory in the root - C:\Go. Then I tried to run Go by opening a command window and typing C:\Go\bin\go.exe   No luck. A command window pops up briefly, and then go away before I can read it. How do you start GO?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Skip Cave

unread,
Jul 8, 2015, 3:02:24 AM7/8/15
to Justin Israel, golan...@googlegroups.com
After fiddling with the environmental variables for a couple of hours, I finally got the Go environment running. Here's my environment settings.

PATH = ......;C:\Go\bin\
GOROOT = C:\Go
GOPATH = C:\Users\xxxx\gostuff\
GOBIN = %GOPATH%bin\

With this environment, I was able to run the Hello World program:

   C:\>go run %GOPATH%bin\hello.go
   hello, world

Also

   C:\>go version
   go version go1.4.2 windows/amd64

Unfortunately, I couldn't get the following to work:

   C:\>go run hello.go
   GetFileAttributesEx hello.go: The system cannot find the file specified.

I put the hello.go program in C:\Users\xxxx\gostuff\bin\  which is the same as %GOPATH%bin\hello.go, which is the same as %GOBIN%. Unfortunately, I still have to list the path to hello.go in the command line. I can't make Go find hello.go using the environmental vars.

In any case, my ultimate goal is to get the skicka Google Drive upload application running, which is written in Go. Here's the link to the Go code in GitHub:

 https://github.com/google/skicka

I need to upload many terrabytes of data to Google Drive, and the skicka utility seems to be the best way to do that. However the install instructions  for skicka aren't very clear, at least to me. The zipped download from GitHub has lots of Go code modules and plenty of docs. Here are the first few steps for installing skicka as described on Github:

  1. You must have a Go compiler installed.
  2. Download and build skicka: go get github.com/google/skicka
  3. Either copy the skicka executable in $GOPATH/bin to a directory in your PATH, or add $GOPATH/bin to your PATH.
  4. Run skicka init to create a skeleton ~/.skicka.config file. Various options can be set in this file to control skicka's operation; see comments in the file for more information.
  5. Authorize skicka to access your Google Drive files: run skicka ls, and skicka will attempt to open an authorization page in your web browser. Click the "Accept" button to authorize skicka. You only need to perform this step once.
    • Alternatively, you can authorize skicka by running skicka -no-browser-auth ls and skicka will ask you to visit a URL: go to the URL in a browser, log into your Google account (if needed), and give permission for the application to access your Google Drive files. After you click 'accept', copy the code from your browser window to the terminal with the "Enter verification code" prompt from skicka.
Several questions:
1. How do you "Build" sckicka?
2. Which one of the many .go modules in the GitHub skicka repository  is the "executable" that I am supposed to copy to somewhere in my PATH?
3. If I can't get Go to find hello.go in the\bin directory, how will it find this "executble"?

I expect I will have more questions, but If I can get through these first steps I will consider this a significant stumble forward.

Skip
 


Skip Cave
Cave Consulting LLC

Justin Israel

unread,
Jul 8, 2015, 6:16:41 AM7/8/15
to Skip Cave, golan...@googlegroups.com
On Wed, Jul 8, 2015 at 7:02 PM Skip Cave <sk...@caveconsulting.com> wrote:
After fiddling with the environmental variables for a couple of hours, I finally got the Go environment running. Here's my environment settings.

PATH = ......;C:\Go\bin\
GOROOT = C:\Go
GOPATH = C:\Users\xxxx\gostuff\
GOBIN = %GOPATH%bin\

With this environment, I was able to run the Hello World program:

   C:\>go run %GOPATH%bin\hello.go
   hello, world

Also

   C:\>go version
   go version go1.4.2 windows/amd64

Unfortunately, I couldn't get the following to work:

   C:\>go run hello.go
   GetFileAttributesEx hello.go: The system cannot find the file specified.

I put the hello.go program in C:\Users\xxxx\gostuff\bin\  which is the same as %GOPATH%bin\hello.go, which is the same as %GOBIN%. Unfortunately, I still have to list the path to hello.go in the command line. I can't make Go find hello.go using the environmental vars.

In any case, my ultimate goal is to get the skicka Google Drive upload application running, which is written in Go. Here's the link to the Go code in GitHub:

 https://github.com/google/skicka
... [snip] ...

Several questions:
1. How do you "Build" sckicka?
2. Which one of the many .go modules in the GitHub skicka repository  is the "executable" that I am supposed to copy to somewhere in my PATH?
3. If I can't get Go to find hello.go in the\bin directory, how will it find this "executble"?


Have you taken the time to review How to Write Go Code? Because it would seem there is a bit of a gap in your understanding of how to build Go code in general, let alone how to build this particular library. To be honest, this library isn't any different than the average Go library, in terms of installation. Because of the ease of Go tooling, there isn't much that the README really needs to say, beyond suggesting that it is go-gettable. 

You do not need to locate and target a specific "executable" .go file within the skicka code repo, in order to build and install it. The source code within that location is a "main" package and builds an executable application. If you following the "go get" instructions from the README, it will end up downloading and running "go install" for you. You will end up with the skicka executable in your $GOPATH. This is the equivalent of cloning the repo to your local $GOPATH, and then running:


When you run this command, go will look in your $GOPATH/src location, find github.com/google/skicka , and then build and install it.

Konstantin Khomoutov

unread,
Jul 8, 2015, 9:47:33 AM7/8/15
to Skip Cave, Justin Israel, golan...@googlegroups.com
On Wed, 8 Jul 2015 02:01:51 -0500
Skip Cave <sk...@caveconsulting.com> wrote:

> After fiddling with the environmental variables for a couple of
> hours, I finally got the Go environment running. Here's my
> environment settings.
>
> PATH = ......;C:\Go\bin\
> GOROOT = C:\Go
> GOPATH = C:\Users\xxxx\gostuff\
> GOBIN = %GOPATH%bin\
[...]

Please drop GOROOT. For long ago, it's set by the `go` tool itself,
so in 99.9% of cases you don't need to mess with this variable.

The same goes to GOBIN: the `go` toolchain knows by itself where it
should put the executables `go install` creates because it's resolved
relative to your current "Go workspace" -- which is defined by GOPATH.

That is, the only variable you should keep is GOPATH, and under the
directory listed in GOPATH you have to create three subdirectories:
"src", "pkg" and "bin". The rest is explained by other folks in this
thread.

Hence a typical setup is something like

GOPATH=C:\Users\xxxx\gostuff
PATH=%PATH%;%GOPATH%\bin

(But note that technically GOPATH can contain multiple workspaces, and
in that case, the latter trick won't work, but that's an advanced case.)

Also note that you are able to know the current idea of the `go`
toolchain about its current environment by running `go env` (in the
shell).

Lucio

unread,
Jul 9, 2015, 1:29:57 PM7/9/15
to golan...@googlegroups.com, justin...@gmail.com
go run hello.go

expects hello.go to be in the current directory (PWD).  It will not look in any type of path automatically, it needs the path to be explicit if it is not (in your Windows case) the default ".\".

Other advice offered covers all other aspects.  Reading the documentation is particularly helpful.

Lucio.

adam willis

unread,
Jul 9, 2015, 5:20:42 PM7/9/15
to golan...@googlegroups.com
I suggest removing anything you did with the path, uninstalling go, and then reinstalling go following the instruction here: http://golang.org/doc/install. You shouldn't need to fiddle with the path.

Read http://golang.org/doc/, but most importantly follow the install instructions linked above, which is part of the docs.

xiio...@gmail.com

unread,
Jul 10, 2015, 9:42:27 AM7/10/15
to golan...@googlegroups.com
I noticed this : I put the hello.go program in C:\Users\xxxx\gostuff\bin\  which is the same as %GOPATH%bin\hello.go, which is the same as %GOBIN%. Unfortunately, I still have to list the path to hello.go in the command line. I can't make Go find hello.go using the environmental vars. 

If I read correctly you are trying to compile a *.go program in the /bin directory..

.go programs should be (and will be found) when put in the /src directory (or /pkg when its a go package) ..

This directory structure is explained here http://golang.org/doc/code.html . reading the first half at least should hopefully save you a time in the long run.
Reply all
Reply to author
Forward
0 new messages