beego快速开始一个项目

429 阅读1分钟

beego快速开始一个项目

查看go的环境信息

go env

beego 安装与升级

# 安装beego
go get github.com/astaxie/beego

# 升级beego
go get -u github.com/astaxie/beego

# 配置bee的使用工具
go get github.com/beego/bee

bee的可执行文件默认放在$GOPATH/bin里面,并添加进环境变量

# 创建新的项目
 bee new myland

项目的目录结构:tree /F

myland
│  main.go   # 主函数
│
├─conf
│      app.conf   # 配置文件
│      
├─controllers
│      default.go
│
├─models     # 数据库相关的操作抽象出来,成为模块
├─routers
│      router.go   
│
├─static # 静态文件
│  ├─css
│  ├─img
│  └─js
│          reload.min.js
│
├─tests
│      default_test.go
│
└─views
        index.tpl

运行项目

cd myland
bee run

浏览器访问 http://127.0.0.1:8080