go get get 代理
go的版本是1.13及以上
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
# 设置不走 proxy 的私有仓库,多个用逗号相隔(可选)
go env -w GOPRIVATE=*.corp.example.com
# 设置不走 proxy 的私有组织(可选)
go env -w GOPRIVATE=example.com/org_name
下载bee
go get github.com/beego/bee
新建项目
bee new appname
在appname 目录中 执行
go mod init appname 会生成 go.mod 文件
go mod tidy -v
go mod vendor -v 会生成vendor文件 包含所有需要的包
设置go get 代理之后 第三方的包不在下载到gopath 的src 目录下 而是在gopath的pkg目录下
不执行 go mod 命令 新建的项目引入的包会报错
bee api
bee api apiapp -driver=mysql -conn="root:<password>@tcp(localhost:3306)/test"
新建api 项目 同时根据表生成model 和controller 代码
但是如果表中字段的类型有int 类型并且该字段不是主键也不是外键 会报错 (数组下标越界)