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 /usr/local/go
(or 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 $HOME/.profile
:
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
The go
tool requires you to organize your code in a specific way.
Workspaces
Go code must be kept inside a workspace. A workspace is a directory hierarchy with three directories at its root:
src
contains Go source files organized into packages (one package per directory),pkg
contains package objects, andbin
contains executable commands.
The go
tool builds source packages and installs the resulting binaries to the pkg
and bin
directories.
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
The 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. PATH=%PATH%;%GOPATH%\bin;
Here’s my folder structure:
C:go_projects +---go +---bin +---pkg +---src
Package paths
The packages from the standard library are given short paths such as fmt
and 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 C:\go_projects\go\src\github.com\SatishTalim
.
Tip: Replace 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 GOPATH\bin
.
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 C:\go_projects\go\src\github.com\SatishTalim\slides
:
Sample Presentation 10 Mar 2014 Tags: go golang Satish Talim Go Hobbyist satish@joshsoftware.com 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
The files talim.jpg
and hello.go
are also in the same folder namely C:\go_projects\go\src\github.com\SatishTalim\slides
You can download these 3 files from here.
Run present.exe
In the folder C:\go_projects\go\src\github.com\SatishTalim\slides
type:
$ 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:
Click on 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:
http://go-talks.appspot.com/github.com/owner/project/file.ext
Thanks to Miki Tebeka for pointing this out.
The sample.slide
that we have created can be seen online here.
That’s it! Have fun!
Reblogged this on narutosanjiv.
Nice blog post, but whats the difference between the tools thats already existing in other languages
It’s now at:
go get golang.org/x/tools/cmd/present
Hi everyone, if you would like to create golang presenter slides in the cloud (not local) so you can create/edit slides on the go & even publish them in the internet, you may want to take a look at our ULAPPH Cloud Desktop system which can do this for you. Here’s a video:
You might ask if it’s free? Currently, we only require a one-time very low payment in order to install the UCD system where the slides will be created/edited/published. After that, you can use the UCD for free! Please visit below site to check our UCD system.
http://www.ulapph.com
And there is even a screenshot tool that we can use to easily insert screenshots in the slides.
And you can even impress the audience by controlling your slides using your Android/IOS phone provided there is Wifi.
Thanks for reading my comment! 🙂