I’m always interested in learning new things and in this case, a new programming language called Go. The Go programming language is open source and developed by Google; which makes it easier to build simple, reliable, and efficient software.Revel is a high-productivity web framework for the Go language. I’m currently using Revel to build a app for travel bloggers, that allows them to create profiles, advertise to possible travel agencies and more.
This tutorial will show you how-to install the Go programming language and Revel, so if you wanted to create your own app, you could.
Installing the Go Programming Language
For this tutorial, I’m using Ubuntu 14.04 x64 with 512 MB of RAM from Digital Ocean.
You can easily install the Go programming language with the following command:
sudo apt-get install golang
If that doesn’t work, you can install the Go programming language through a PPA repository:
sudo apt-get update sudo add-apt-repository ppa:gophers/go sudo apt-get update sudo apt-get install golang-stable
Let’s make sure the Go programming language is installed:
You should get a result like:
go version go1.2.1 linux/amd64
Next we will install Revel.
Make a directory called
gocode. You can change the directory if you wish but you will need to modify the next two (2) command lines.
Now let’s set the GOPATH:
Save the GOPATH:
echo export GOPATH=$GOPATH >> ~/.bash_profile
We will now install Git and Mercurial, as they are required for
go get to clone various dependencies.
sudo apt-get install git
sudo apt-get install mercurial
go get Revel:
go get github.com/revel/revel
Next we will build the Revel command line tool, which we will need to build, run, and package Revel applications.
go get github.com/revel/cmd/revel export PATH=”$PATH:$GOPATH/bin” echo ‘export PATH=”$PATH:$GOPATH/bin”‘ >> ~/.bash_profile
We should be good to go now. As always, we should test to make sure:
You will receive an output of available commands for Revel and how-to use them.
Creating Your First Revel App
Now that we have installed Go and Revel, let’s make our first app:
Note: Running the command
revel help will also show you how-to create and run Revel applications.
You can create a new app like this:
revel new myapp
myapp is the named of the app and the directory in which the app would be contained.
Now that we have created the
myapp app, we will need to run it so that it publicly appears.
revel run myapp
To see the
myapp app running, go to: http://:9000/. Where
<ip-address> is the server’s IP address.
If you want your app to run on port 80, which will not use a port number in the URL, go to your app’s
conf directory and look for the
app.conf file. Look for
http.port=9000 and change it to
Here is what it looks like (uses the Revel skeleton app code):