Skip to content

Commit

Permalink
fix 4384 & using commentsRouter as fix name
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash committed Dec 22, 2020
1 parent 6602ca8 commit e103a0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
@@ -1 +1,3 @@
# developing
# developing
- Fix `unknown escape sequence` in generated code. []()
- Using fixed name `commentRouter.go` as generated file name. []()
14 changes: 7 additions & 7 deletions server/web/parser.go
Expand Up @@ -50,7 +50,6 @@ func init() {

var (
lastupdateFilename = "lastupdate.tmp"
commentFilename string
pkgLastupdate map[string]int64
genInfoList map[string][]ControllerComments

Expand All @@ -71,16 +70,13 @@ var (
}
)

const commentPrefix = "commentsRouter_"
const commentFilename = "commentsRouter.go"

func init() {
pkgLastupdate = make(map[string]int64)
}

func parserPkg(pkgRealpath string) error {
rep := strings.NewReplacer("\\", "_", "/", "_", ".", "_")
commentFilename, _ = filepath.Rel(AppPath, pkgRealpath)
commentFilename = commentPrefix + rep.Replace(commentFilename) + ".go"
if !compareFile(pkgRealpath) {
logs.Info(pkgRealpath + " no changed")
return nil
Expand All @@ -102,7 +98,10 @@ func parserPkg(pkgRealpath string) error {
if specDecl.Recv != nil {
exp, ok := specDecl.Recv.List[0].Type.(*ast.StarExpr) // Check that the type is correct first beforing throwing to parser
if ok {
parserComments(specDecl, fmt.Sprint(exp.X), pkg.PkgPath)
err = parserComments(specDecl, fmt.Sprint(exp.X), pkg.PkgPath)
if err != nil {
return err
}
}
}
}
Expand Down Expand Up @@ -500,7 +499,8 @@ func genRouterCode(pkgRealpath string) {
beego.GlobalControllerRouter["` + k + `"] = append(beego.GlobalControllerRouter["` + k + `"],
beego.ControllerComments{
Method: "` + strings.TrimSpace(c.Method) + `",
` + `Router: "` + c.Router + `"` + `,
` + "Router: `" + c.Router + "`" + `,
AllowHTTPMethods: ` + allmethod + `,
MethodParams: ` + methodParams + `,
Filters: ` + filters + `,
Expand Down

0 comments on commit e103a0c

Please sign in to comment.