Download and Install Go
It goes without saying that you need to have Go installed on your computer.
Just for completeness, visit the Go project’s downloads page and select the binary distribution that matches your operating system and processor architecture.
The Go binary distributions assume they will be installed in
c:\Go under Windows), but it is possible to install them in a different location. If you do this, you will need to set the
GOROOT environment variable to that directory when using the Go tools.
For example, if you installed Go to your home directory you should add the following commands to
export GOROOT=$HOME/go export PATH=$PATH:$GOROOT/bin
Under Windows, you may set environment variables through the “Environment Variables” button on the “Advanced” tab of the “System” control panel. Some versions of Windows provide this control panel through the “Advanced System Settings” option inside the “System” control panel. Edit the
PATH-variable as follows:
C:\go\bin; ...rest of PATH...
Go Code Organization
go tool requires you to organize your code in a specific way.
Go code must be kept inside a workspace. A workspace is a directory hierarchy with three directories at its root:
srccontains Go source files organized into packages (one package per directory),
pkgcontains package objects, and
bincontains executable commands.
go tool builds source packages and installs the resulting binaries to the
src subdirectory typically contains version control repositories (such as for Git) that track the development of one or more source packages.
The GOPATH environment variable
GOPATH environment variable specifies the location of your workspace.
To get started, create a workspace directory and set
GOPATH accordingly. Your workspace can be located wherever you like. Note that this must not be the same path as your Go installation.
On my Windows computer, I have set
GOPATH=C:\go_projects\go. Next I update my system environment variable
PATH to include my workspace
bin subdirectory i.e.
Here’s my folder structure:
C:go_projects +---go +---bin +---pkg +---src
The packages from the standard library are given short paths such as
net/http. For your own packages, you must choose a base path that is unlikely to collide with future additions to the standard library or other external libraries. If you have a GitHub account at
github.com/user, that should be your base path. We will use
github.com/user as our base path. Create a directory inside your workspace in which to keep source code. I have created the folder
SatishTalim with your own username.
Download and use package present
We shall use the Go package present to create our presentation. First, we need to use the
go get command to download and install the package and its dependencies.
$ go get code.google.com/p/go.tools/cmd/present
On Windows the
present.exe file is created in the folder
Thanks to Dave Cheney for resolving an issue I had with the above command.
Write your .slide file
We need to write our
.slide file as per the format specified here.
Here’s a file
sample.slide in the folder
Sample Presentation 10 Mar 2014 Tags: go golang Satish Talim Go Hobbyist firstname.lastname@example.org http://satishtalim.com/ @IndianGuru * Who is this guy? .image ./talim.jpg - Programming addict - C, Java, Ruby, Go - Director, JoshSoftware .link http://www.joshsoftware.com/team The JoshSoftware team * Example Go code .play hello.go
hello.go are also in the same folder namely
You can download these 3 files from here.
In the folder
$ present 2014/03/10 04:22:37 Open your web browser and visit http://127.0.0.1:3999/
In your browser type http://127.0.0.1:3999/ and you should see:
sample.slide and you should be able to see the presentation.
Also, go-talks.appspot plays slide presentations stored on GitHub in the
present format. The syntax for GitHub URLs is:
Thanks to Miki Tebeka for pointing this out.
sample.slide that we have created can be seen online here.
That’s it! Have fun!