gogogo-bee框架

进入基础教程

初始化项目

命令执行

# 新建 指定三张表
bee api pretty-admin -tables="sys_user,sys_role,sys_menu" -driver=mysql -conn="root:@tcp(127.0.0.1:3306)/test-cc"
# 新建 指定一张表
bee api pretty-admin -tables="sys_dict" -driver=mysql -conn="root:@tcp(127.0.0.1:3306)/test-cc"
  • 输出
# 先cd进入src目录,避免出现下面这句
You current workdir is not inside $GOPATH/src.
# 成功
22:55:49 SUCCESS  ▶ 0010 New API successfully created!
  • 跑起来
# cd pretty-admin
# bee run之后的文档配置最好带上
bee run -gendoc=true -downdoc=true

解决报错

报错了:
cannot find package "github.com/astaxie/beego" in any of:

加速
set GO111MODULE=on
go get github.com/astaxie/beego

又报错了:
cannot find main module

go mod init
out:go: creating new go.mod: module pretty/pretty-admin
  • 再次运行:
    成功out:
SUCCESS  ▶ 0007 './pretty-admin.exe' is running...
http server Running on http://:8080

成功运行

  • 解决报错
    Not Found 404
    解决办法:加上swagger/
    完整地址:
    gogogo-bee框架_第1张图片
    gogogo-bee框架_第2张图片

调用接口

报错的处理

如果调用失败,报404/403等,
检查routers目录是不是少个文件:commentsRouter_controllers.go
就重新执行bee api projectName;bee run -gendoc=true -downdoc=true,但是会重新创建目录
如果在原根目录创建相同名称的项目,系统会提示:
在这里插入图片描述

维护

增加新表CRUD
现在有几张表的增删改查了,但是如果新增表会不会覆盖原代码呢

你可能感兴趣的:(go语言,bee,代码生成)