Install Go

Before you can use Revel, first you need to install Go.

If you have not created a GOPATH as part of the installation, do so now. The GOPATHis a directory where all of your Go code will live. Here is one way of setting it up:

  • Make a directory: mkdir ~/gocode
  • Tell Go to use that as your GOPATH: export GOPATH=~/gocode
  • Save your GOPATH so that it will apply to all future shell sessions: echo export GOPATH=$GOPATH >> ~/.bashprofile
    Note that depending on your shell, you may need to adjust (3) to write the export into a different configuration file (e.g.
    ~/.bashrc_, *~/.zshrc, etc.).

Now your Go installation is complete.

Install git and hg

Git and Mercurial are required to allow go get to clone various dependencies.

To get the Revel framework, run

  1. go get github.com/revel/revel

This command does a couple of things:

  • Go uses git to clone the repository into $GOPATH/src/github.com/revel/revel/
  • Go transitively finds all of the dependencies and runs go get on them as well.

    Get and Build the Revel command line tool

The revel command line tool is used to build, run, and package Revel applications.

Use go get to install:

  1. go get github.com/revel/cmd/revel

Ensure the $GOPATH/bin directory is in your PATH so that you can reference the command from anywhere.

  1. export PATH="$PATH:$GOPATH/bin"

Verify that it works:

  1. $ revel help
  2. ~
  3. ~ revel! http://revel.github.io
  4. ~
  5. usage: revel command [arguments]
  6. The commands are:
  7. new create a skeleton Revel application
  8. run run a Revel application
  9. build build a Revel application (e.g. for deployment)
  10. package package a Revel application (e.g. for deployment)
  11. clean clean a Revel application's temp files
  12. test run all tests from the command-line
  13. Use "revel help [command]" for more information.

原文: https://revel.github.io/tutorial/gettingstarted.html