Go language Revel Environment building

Source: Internet
Author: User
Tags install go mongodb client mysql client
This is a creation in Article, where the information may have evolved or changed.

1. Install Go

1.1. OS X

1.1.1, installation Homebrew

Run the following command in Terminal:

$ RUBY-E "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ Brew Update


1.1.2, install Go

$ Brew Install Go


1.2. Ubuntu

$ sudo apt-get update

$ sudo apt-get install go


1.3. Windows

Please download the installation package yourself

64bit Https://storage.googleapis.com/golang/go1.4.1.windows-amd64.msi

32bit Https://storage.googleapis.com/golang/go1.4.1.windows-386.msi


2. Configure the development environment

2.1. Configure Golang Environment

2.1.1, creating Go Path

Create a folder in a directory with permissions Go_path, the code directory for Golang


2.1.2, configuring environment variables

Edit File ~/.bash_profile (OS X) ~/.BASHRC (Ubuntu)

Increase as the downside

Export gopath={your Go_path path}

Export path= "$GOPATH/bin: $PATH"


2.1.3, loading environment variables

Run the following command in Terminal:

$ source ~/.bash_profile (OS X)

$ source ~/. BASHRC (Ubuntu)


2.2, download the dependency package

Go get Golang.org/x/tools/cmd/vet

Go get Golang.org/x/tools/cmd/godoc

Go get Github.com/nsf/gocode

Go get github.com/jstemmer/gotags

#MongoDB Client

Go get gopkg.in/mgo.v2

#Mysql Client

Go get Github.com/go-sql-driver/mysql

#Redis Client

Go get Github.com/garyburd/redigo/redis


2.3. Configure Revel Environment

Go get Github.com/revel/revel

Go get Github.com/revel/cmd/revel


2.4. Create Revel Application

Run the following command in terminal

$ revel New {Your domain name}/{app name}


Revel will create a web app in $gopath/src/{your domain name}/{app name}/directory


Run the following command in terminal and run the Web app on port 9000

$ revel Run {Your domain name}/{application name} PROD 9000


3. Revel Code Structure

Public/is the placement of static files such as Js/css/fonts/img

app/is the code directory

app/controllers/the source file where the controller layer is placed

app/views/Place the source file of the view layer

App/views/app/is the view that the controller corresponds to App/controllers/app.go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.