bee 工具简介

bee 工具是一个为了协助快速开发 beego 项目而创建的项目,通过 bee 您可以很容易的进行 beego 项目的创建、热编译、开发、测试、和部署。

bee 工具的安装

命令行运行下面命令

go get github.com/beego/bee

错误处理

1、git https 无法获取时,请配置本地的 git,关闭 https 验证

git config --global http.sslVerify false

2、出现dial tcp 172.217.160.113:443: connect: connection refused错误,设置go代理

go env -w GOPROXY=https://goproxy.cn

3、出现cannot find module providing package错误,设置go111module

go env -w GO111MODULE=on

在命令行执行 bee 后如果出现项目的提示表示安装 bee 成功

D:\go\src>bee
2022/05/14 18:06:37 INFO     ▶ 0001 Getting bee latest version...
2022/05/14 18:06:38 WARN     ▶ 0002 Update available 1.12.0 ==> 2.0.2
2022/05/14 18:06:38 WARN     ▶ 0003 Run `bee update` to update
2022/05/14 18:06:38 INFO     ▶ 0004 Your bee are up to date
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
    pro         Source code generator
    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
    update      Update Bee

Use bee help [command] for more information about a command.

ADDITIONAL HELP TOPICS

使用 bee new 创建项目

D:\go\src>bee new testbeego
2022/05/14 18:07:08 INFO     ▶ 0001 generate new project support go modules.
2022/05/14 18:07:08 INFO     ▶ 0002 Creating application...
        create   D:\go\src\testbeego\go.mod
        create   D:\go\src\testbeego\
        create   D:\go\src\testbeego\conf\
        create   D:\go\src\testbeego\controllers\
        create   D:\go\src\testbeego\models\
        create   D:\go\src\testbeego\routers\
        create   D:\go\src\testbeego\tests\
        create   D:\go\src\testbeego\static\
        create   D:\go\src\testbeego\static\js\
        create   D:\go\src\testbeego\static\css\
        create   D:\go\src\testbeego\static\img\
        create   D:\go\src\testbeego\views\
        create   D:\go\src\testbeego\conf\app.conf
        create   D:\go\src\testbeego\controllers\default.go
        create   D:\go\src\testbeego\views\index.tpl
        create   D:\go\src\testbeego\routers\router.go
        create   D:\go\src\testbeego\tests\default_test.go
        create   D:\go\src\testbeego\main.go
2022/05/14 18:07:08 SUCCESS  ▶ 0003 New application successfully created!

将依赖包复制到项目的vendor目录下

go mod vendor

最后生成的文件目录结构 

bee run 启动项目

测试访问项目