Beego官网
beego官网 : https://beego.me/
github : https://github.com/beego

Beego安装
前提: ①Go 1.1+ 以确保所有功能的正常使用②安装 Beego 和 Bee 的开发工具③需要设置环境变量GOPATH④这里使用git命令下载,需要下载安装git,并配置git环境变量

检查go环境变量

C:\Users\Administrator>go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\goproject //这里设置了gopath
set GORACE=
set GOROOT=D:\go
set GOTMPDIR=
set GOTOOLDIR=D:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length= -fdebug-prefix-map=C:\Users\ADMINI~\AppData\Local\Temp
\go-build126928446=/tmp/go-build -gno-record-gcc-switches

当然环境变量也可以通过在dos窗口临时设置,这里不做演示

$ go get github.com/astaxie/beego //git命令下载beego
$ go get github.com/beego/bee //git命令下载bee工具
//beege和bee是两个概念,beego是框架,bee是工具,是命令。

正因为需要用beego框架开发项目,所以一般的项目目录结构为下图

如果我们一步步创建这些目录文件,那么就很浪费时间了,这时候用到bee工具,一步步接着走

D:\>bee //执行bee命令(当然也可以忽略上一步配置环境变量,直接进入目录执行bee命令)
Bee is a Fast and Flexible tool for managing your Beego Web Application. USAGE
bee command [arguments] AVAILABLE COMMANDS version Prints the current Bee version
migrate Runs database migrations
api Creates a Beego API application
bale Transforms non-Go files to Go source files
fix Fixes your application by making it compatible with newer versions of Beego
dlv Start a debugging session using Delve
dockerize Generates a Dockerfile for your Beego application
generate Source code generator
hprose Creates an RPC application based on Hprose and Beego frameworks
new Creates a Beego application
pack Compresses a Beego application into a single file
rs Run customized scripts
run Run the application by starting a local development server
server serving static content over HTTP on port Use bee help [command] for more information about a command. ADDITIONAL HELP TOPICS Use bee help [topic] for more information about that topic.

new 命令:new命令创建一个Web项目,我们在命令下执行bee new <项目名>就可以创建一个新的项目。

api命令:上面的new命令是用来创建新Web项目,不过很多用户使用beego来开发API应用,所以api命令是用来创建API应用

执行命令创建项目

D:\>bee new test  //这里因为配置了bee环境变量,可以直接这样new。否则需要进入GOPATH/src下执行
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.10.0
// :: WARN ▶ You current workdir is not inside $GOPATH/src.
// :: INFO ▶ Creating application...
create D:\goproject\src\test\
create D:\goproject\src\test\conf\
create D:\goproject\src\test\controllers\
create D:\goproject\src\test\models\
create D:\goproject\src\test\routers\
create D:\goproject\src\test\tests\
create D:\goproject\src\test\static\
create D:\goproject\src\test\static\js\
create D:\goproject\src\test\static\css\
create D:\goproject\src\test\static\img\
create D:\goproject\src\test\views\
create D:\goproject\src\test\conf\app.conf
create D:\goproject\src\test\controllers\default.go
create D:\goproject\src\test\views\index.tpl
create D:\goproject\src\test\routers\router.go
create D:\goproject\src\test\tests\default_test.go
create D:\goproject\src\test\main.go
// :: SUCCESS ▶ New application successfully created!

启动服务

D:\goproject\src\test>go run main.go  //启动服务
// ::52.865 [I] [asm_amd64.s:] http server Running on http://:8080 //监听8080
[beego] // - :: | ::| | .0076ms| match| GET / r:/
[beego] // - :: | ::| | .0022ms| match| GET /static/js/reload.min.js
[beego] // - :: | ::| | .0156ms| match| GET / r:/
[beego] // - :: | ::| | 0s| match| GET /static/js/reload.min.js

访问本地web

因为默认绑定的是8080端口,所以本地访问http://localhost:8080/

最新文章

  1. 如何设置Oracle客户端与服务器的字符集一致
  2. 基于MVC4+EasyUI的Web开发框架形成之旅--基类控制器CRUD的操作
  3. 学习笔记——Maven实战(八)常用Maven插件介绍(下)
  4. ArrayList、linklist、list的区别
  5. 06.Hibernate实体类生命周期
  6. C#当中的多线程_任务并行库(上)
  7. xslt中的常用函数
  8. 在Eclipse中运行Nutch2.3
  9. jQuery 动态绑定的点击事件
  10. web service接口测试工具选型
  11. MFC多线程各种线程用法 .
  12. JS中的闭包问题
  13. Codeforces 581F Zublicanes and Mumocrates 树形dp
  14. ab与nc命令,tcpdump命令
  15. Session 和 Cookie的区别
  16. 三: vue组件开发及自动化工具vue-cli
  17. Kafka数据可靠性深度解读
  18. kali kvm Requested operation is not valid: network &#39;default&#39; is not active
  19. VS2015编译GEOS3.5.1源码
  20. java语言的各种输入情况(ACM常用)

热门文章

  1. Py中reshape中的-1表示什么【转载】
  2. 【LeetCode每天一题】Merge Two Sorted Lists(合并两个排序链表)
  3. cocos2d JS-(JavaScript) 基础语法运算符
  4. System.ArgumentException: 目标数组的长度不够。请检查 destIndex 和长度以及数组的下限
  5. @AfterThrowing
  6. MFC 运行报错:Debug Assertion Failed! dbgheap.c
  7. java生成随机六位数的验证码&amp;随机生成十位数ValidCode码,用于邮件的验证&amp;检查是不是符合为合法的中国的手机号码
  8. [3]windows内核情景分析--内存管理
  9. 加载MySQL、Oracle、SQL Server 2000、SQL Server 2005及以上版本 的加载数据库驱动程序
  10. 实战http切换成https