This is a creation in Article, where the information may have evolved or changed.
"Preface" cat Brother because of the project needs, beginners to practice go language and beego framework, please correct me.
0. Install git in advance, and don't repeat the steps.
1. The go language is Google's new programming language that can reduce the complexity of your code without compromising application performance. The go language can be used in Web servers, storage systems, and database development.
The goal of GO is to improve the management of existing programming languages such as library dependencies (dependency), which are called repeatedly by applications. Because of the parallel programming pattern, this language is also designed to solve multiprocessor tasks.
Go to the official website (https://code.google.com/p/go/downloads/list) to download go Windows Installer, it is best to find the MSI file, easy to install.
The Windows platform installs all the way next, without words, except to set the installation path in D:\go.
Note: Go language installation path avoid Chinese , Otherwise there will be problems.
Set the Windows environment variable goroot = D:\go, and append the path variable%goroot%\bin.
In addition, pay extra attention to building a gopath. Do not use Chinese in the specific place there is no so-called. Brother Cat put it in the D:\go\GoDev. Similarly, set the Windows environment variable Gopath=d:\go\godev.
Open a command-line window
C:\>go version
Go version go1.5.1 windows/amd64
Congratulations! Go language installation is complete!
3. Beego is an application framework developed with go, the idea comes from the tornado, routing design from Sinatra, support the following features
Mvc
REST
Smart Routing
Log debugging
Configuration Management
Automatic template rendering
Layout design
Middleware insertion Logic
Convenient Json/xml Service
Windows7 64bit system, you need to install Go 1.1+ to ensure the normal use of all functions.
The process of two pits:
3.1 The first pit: Gopath (The pit daddy's official online didn't mention ...) ), see above text description. Otherwise, you will encounter an error such as "Gopath" not set.
3.2 The second pit compares that what ... Step by step:
First, according to the official website
$ go Get GitHub . com / Astaxie / Beego
$ go Get GitHub . com / Beego / Bee
Windows executes at the command line, in which directory is not called.
Execute go get github.com/astaxie/beego error, say is SSL authentication problem, timeout ... The root is on git settings.
Git command line executes $ git config--global http.sslverify false
Then, again git config--global http.sslverify false, no error, after a few minutes, execution finished.
Switch directories to D:\Go\GoDev\src\github.com\astaxie\beego, a whole bunch of file directories are down. Description git checkout complete.
Next, go to go get GitHub. com / Beego / Bee, a few minutes of success.
If you want to, add another path environment variable%gopath%/bin; (otherwise bee new Hello on the official website, there will be an unrecognized bee error, in fact, it is a pit ...) )
After setting the environment variables, remember to reopen the command line window Oh ~
Command line:
CD%gopath%\src\
Bee New Hello
To avoid port collisions, cat brother's local port 8080 has been given to Jenkins. Wronged later Beego, with 8099 Bar. Change%gopat%\src\hello\conf\app.conf inside content httpport = 8099.
Command line:
Bee Run Hello
Open Browser, enter http://localhost:8099/
The following page appears stating that the Beego installation is complete.
Potential pit-do not use GIT to checkout directly, you must use go get ...
4. Write a beego Hello World
Under the%gopath%\scr\hello path, write the Hello.go file with the contents:
Package Mainimport ( "Github.com/astaxie/beego") type Maincontroller struct { beego. Controller}func (This *maincontroller) Get () {this . Ctx.writestring ("Hello Beego ' s World")}func main () { Beego. Router ("/", &maincontroller{}) Beego. Run ()}
Remember: Do not change the position of parentheses, whether it is curly braces, parentheses, otherwise ...
Another hole has appeared (pure crossing Web document will make you very confused ...) ):
1) Change the original hello.exe to a name or copy it elsewhere.
2) Compile Go build -o hello.exe Hello. Go
3) run. \hello.exe
Open the browser, enter http://localhost:8099/appears a line Hello Beego ' s world!
To this end!!!
"PostScript" are the process of solving problems themselves, to treat everyone!
Reference: Http://beego.me/quickstart