| \ | |/ / __ | \ / \ / \ | |/ /| /| / ___/ \| ___| v2.0.2
├── Beego : Beego is not installed. Please do consider installing it first: https://github.com/beego/beego/v2. If you are using go mod, and you don't install the beego under $GOPATH/src/github.com/astaxie, just ignore this. ├── GoVersion : go1.15.6 ├── GOOS : linux ├── GOARCH : amd64 ├── NumCPU : 4 ├── GOPATH : /datas/e_drive/goproject ├── GOROOT : /home/sakura/apphome/go ├── Compiler : gc └── Date : Monday, 11 Jan 2021
“GO ENV“ GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/home/sakura/.cache/go-build" GOENV="/home/sakura/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/datas/e_drive/goproject/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/datas/e_drive/goproject" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/sakura/apphome/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/sakura/apphome/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build843580340=/tmp/go-build -gno-record-gcc-switches"
我需要写一个类似”@router /Level [get]“的接口 但是自动话文档生成了这个接口之后调用经常404
后来我那bee api生成的样例直接测试也是会404
controllers/object.go `package controllers
import ( "muapi/models" "encoding/json"
beego "github.com/beego/beego/v2/server/web"
)
// Operations about object type ObjectController struct { beego.Controller }
// @Title Create // @Description create object // @Param body body models.Object true "The object content" // @Success 200 {string} models.Object.Id // @Failure 403 body is empty // @router /test [post] func (o *ObjectController) Post() { var ob models.Object json.Unmarshal(o.Ctx.Input.RequestBody, &ob) objectid := models.AddOne(ob) o.Data["json"] = map[string]string{"ObjectId": objectid} o.ServeJSON() }
// @Title GetAll // @Description get all objects // @Success 200 {object} models.Object // @Failure 403 :objectId is empty // @router / [get] func (o *ObjectController) GetAll() { obs := models.GetAll() o.Data["json"] = obs o.ServeJSON() }`
routers/commentsRouter_controllers.go `package routers
import ( beego "github.com/beego/beego/v2/server/web" "github.com/beego/beego/v2/server/web/context/param" )
func init() {
beego.GlobalControllerRouter["muapi/controllers:ObjectController"] = append(beego.GlobalControllerRouter["muapi/controllers:ObjectController"],
beego.ControllerComments{
Method: "GetAll",
Router: "/",
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["muapi/controllers:ObjectController"] = append(beego.GlobalControllerRouter["muapi/controllers:ObjectController"],
beego.ControllerComments{
Method: "Post",
Router: "/test",
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
……`
尝试过删除commentsRouter_controllers.go文件再启动也是不行。