This is a creation in Article, where the information may have evolved or changed.
Revel Frame Installation
Official website: http://revel.github.io/tutorial/index.html
Chinese community: http://www.gorevel.cn/
First, install the Revel frame
Download the Revel framework source code, put its source into the%gopath%src/github.com/revel/revel directory, and then in the%GOPATH%SRC directory to compile operations:
Compiling: Go build github.com/revel/revel
The result is an error, as follows:
Src\github.com\revel\revel\revel.go:17:2: Cannot find package "Github.com/ag
Torre/gocolorize "In any of:
D:\Go\src\github.com\agtorre\gocolorize (from $GOROOT)
D:\GO_WorkSpace\src\github.com\agtorre\gocolorize (from $GOPATH)
Src\github.com\revel\revel\compress.go:13:2: Cannot find package "github.com
/klauspost/compress/gzip "In any of:
D:\Go\src\github.com\klauspost\compress\gzip (from $GOROOT)
D:\GO_WorkSpace\src\github.com\klauspost\compress\gzip (from $GOPATH
)
Src\github.com\revel\revel\compress.go:14:2: Cannot find package "github.com
/klauspost/compress/zlib "In any of:
D:\Go\src\github.com\klauspost\compress\zlib (from $GOROOT)
D:\GO_WorkSpace\src\github.com\klauspost\compress\zlib (from $GOPATH
)
Src\github.com\revel\revel\i18n.go:15:2: Cannot find package "Github.com/rev
El/config "In any of:
D:\Go\src\github.com\revel\config (from $GOROOT)
D:\GO_WorkSpace\src\github.com\revel\config (from $GOPATH)
Src\github.com\revel\revel\router.go:18:2: Cannot find package "github.com/r
Evel/pathtree "In any of:
D:\Go\src\github.com\revel\pathtree (from $GOROOT)
D:\GO_WorkSpace\src\github.com\revel\pathtree (from $GOPATH)
Import Cycle not allowed
Package Github.com/revel/revel
Imports Golang.org/x/net/websocket
Imports Golang.org/x/net/websocket
Src\golang.org\x\net\websocket\watcher.go:13:2: Cannot find package "gopkg.i
N/fsnotify.v1 "In any of:
D:\Go\src\gopkg.in\fsnotify.v1 (from $GOROOT)
D:\GO_WorkSpace\src\gopkg.in\fsnotify.v1 (from $GOPATH)
Depending on the error message, download the following packages separately:
Github.com/agtorre/gocolorize
Github.com/klauspost/compress
Github.com/revel/config
Github.com/revel/pathtree
Golang.org/x/net
Gopkg.in/fsnotify.v1
The source of each package is stacked under the corresponding path. Then execute again:
Go Build Github.com/revel/revel
Compilation succeeded
Second, install Revel Command line tool
Download the Revel Command line tool source code, put its source into the%gopath%src/github.com/revel/cmd directory, and then in the%GOPATH%SRC directory to compile operations:
Compiling: Go build github.com/revel/cmd/revel
The result is an error, as follows:
D:\go_workspace\src\github.com\revel\cmd\revel\test.go:19:2: Cannot find package "Github.com/revel/modules/testrun Ner/app/controllers "In any of:
D:\Go\src\github.com\revel\modules\testrunner\app\controllers (from $GOROOT)
D:\GO_WorkSpace\src\github.com\revel\modules\testrunner\app\controllers (from $GOPATH)
Depending on the error message, download the following package:
Github.com/revel/modules
The source is stacked under the corresponding path. Then execute again:
Go Build Github.com/revel/cmd/revel
Compilation succeeded
Iii. Creating Revel applications
Restart the command-line tool, and then create the Revel app in the%GOPATH%SRC directory.
Command:
Revel New Myrevelapp
Revel Run Myrevelapp
Iv. Open Browser Access http://localhost:9000
The default listener is 9000 ports.
V. Revel directive
1, Revel
Enter ' Revel ' on the command line to get instructions for all Revel instructions:
Usage:revel command [arguments]
The commands are:
new Create a Skeleto N Revel Application
run & nbsp Run a Revel application
build Build a Revel application (e.g. for deployment)
Package Package a Revel application (e.g Deployment)
and nbsp; clean Clean a Revel application ' s temp files
&N bsp; test run all tests from the command-line
&N Bsp version Displays the Revel Framework and Go version
Use ' Revel Help [command] ' for more information.
2. Revel Help [command]
Revel Help [command] is used to obtain instructions for instructions. Cases:
Enter ' Revel help new ' at the command line to get all the instructions for the new directive:
Usage:revel new [path] [skeleton]
New creates a few files to get a new Revel application running quickly.
It puts all of the files on the given import path, taking the final element in
The path to is the app name.
Skeleton is a optional argument, provided as an import path
For example:
Revel New Import/path/helloworld
Revel New Import/path/helloworld Import/path/skeleton
Vi. the MVC pattern concept of Revel framework
MVC (Model-View-Controller):
Model: Describes basic data objects, specific query and update logic.
Views: Some templates that are used to present data to users.
Controller: Executes the user's request, prepares the data required by the user, and specifies the template for rendering.
Specific reference:
Http://www.gorevel.cn/docs/manual/concepts.html
Vii.. Revel Routing Configuration
Configuring the routes file in the Conf directory
Specific reference:
Http://www.gorevel.cn/docs/manual/routing.html
391 Reads