Merge pull request #4385 from flycash/develop
fix 4384 & using commentsRouter as generated file name
This commit is contained in:
commit
f45438f09c
@ -1 +1,3 @@
|
|||||||
# developing
|
# developing
|
||||||
|
- Fix `unknown escape sequence` in generated code. [4385](https://github.com/beego/beego/pull/4385)
|
||||||
|
- Using fixed name `commentRouter.go` as generated file name. [4385](https://github.com/beego/beego/pull/4385)
|
||||||
@ -50,7 +50,6 @@ func init() {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
lastupdateFilename = "lastupdate.tmp"
|
lastupdateFilename = "lastupdate.tmp"
|
||||||
commentFilename string
|
|
||||||
pkgLastupdate map[string]int64
|
pkgLastupdate map[string]int64
|
||||||
genInfoList map[string][]ControllerComments
|
genInfoList map[string][]ControllerComments
|
||||||
|
|
||||||
@ -71,16 +70,13 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const commentPrefix = "commentsRouter_"
|
const commentFilename = "commentsRouter.go"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pkgLastupdate = make(map[string]int64)
|
pkgLastupdate = make(map[string]int64)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parserPkg(pkgRealpath string) error {
|
func parserPkg(pkgRealpath string) error {
|
||||||
rep := strings.NewReplacer("\\", "_", "/", "_", ".", "_")
|
|
||||||
commentFilename, _ = filepath.Rel(AppPath, pkgRealpath)
|
|
||||||
commentFilename = commentPrefix + rep.Replace(commentFilename) + ".go"
|
|
||||||
if !compareFile(pkgRealpath) {
|
if !compareFile(pkgRealpath) {
|
||||||
logs.Info(pkgRealpath + " no changed")
|
logs.Info(pkgRealpath + " no changed")
|
||||||
return nil
|
return nil
|
||||||
@ -102,7 +98,10 @@ func parserPkg(pkgRealpath string) error {
|
|||||||
if specDecl.Recv != nil {
|
if specDecl.Recv != nil {
|
||||||
exp, ok := specDecl.Recv.List[0].Type.(*ast.StarExpr) // Check that the type is correct first beforing throwing to parser
|
exp, ok := specDecl.Recv.List[0].Type.(*ast.StarExpr) // Check that the type is correct first beforing throwing to parser
|
||||||
if ok {
|
if ok {
|
||||||
parserComments(specDecl, fmt.Sprint(exp.X), pkg.PkgPath)
|
err = parserComments(specDecl, fmt.Sprint(exp.X), pkg.PkgPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,7 +499,8 @@ func genRouterCode(pkgRealpath string) {
|
|||||||
beego.GlobalControllerRouter["` + k + `"] = append(beego.GlobalControllerRouter["` + k + `"],
|
beego.GlobalControllerRouter["` + k + `"] = append(beego.GlobalControllerRouter["` + k + `"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "` + strings.TrimSpace(c.Method) + `",
|
Method: "` + strings.TrimSpace(c.Method) + `",
|
||||||
` + `Router: "` + c.Router + `"` + `,
|
|
||||||
|
` + "Router: `" + c.Router + "`" + `,
|
||||||
AllowHTTPMethods: ` + allmethod + `,
|
AllowHTTPMethods: ` + allmethod + `,
|
||||||
MethodParams: ` + methodParams + `,
|
MethodParams: ` + methodParams + `,
|
||||||
Filters: ` + filters + `,
|
Filters: ` + filters + `,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user