//在linux系统里面操作下载
//你需要安装或者升级 Beego 和 Bee 的开发工具:
$ go get -u github.com/astaxie/beego
$ go get -u github.com/beego/bee
# 如果您还没添加 $GOPATH 变量
$ echo 'export GOPATH="$HOME/go"' >> ~/.profile # 或者 ~/.zshrc, ~/.cshrc, 您所使用的sh对应的配置文件
# 如果您已经添加了 $GOPATH 变量
$ echo 'export PATH="$GOPATH/bin:$PATH"' >> ~/.profile # 或者 ~/.zshrc, ~/.cshrc, 您所使用的sh对应的配置文件
$ exec $SHELL
$ cd $GOPATH/src
$ bee new hello
$ cd hello
$ bee run hello
下面这个示例程序将会在浏览器中打印 “Hello world”,以此说明使用 beego 构建 Web 应用程序是多么的简单!
package main
import (
"github.com/astaxie/beego"
)
type MainController struct {
beego.Controller
}
func (this *MainController) Get() {
this.Ctx.WriteString("hello world")
}
func main() {
beego.Router("/", &MainController{})
beego.Run()
}
把上面的代码保存为 hello.go,然后通过命令行进行编译并执行:
$ go build -o hello hello.go
$ ./hello
参照学习资料:https://beego.me/
下面我们将会带大家写一个聊天室。
$ bee new mychat 创建一个chat来工作