mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:30:56 +00:00
Merge pull request #3583 from maxshine/develop
[Fix] Fix the issue that genRouterCode results in @Import annotations getting overwritten
This commit is contained in:
commit
f294121ab7
10
parser.go
10
parser.go
@ -459,13 +459,17 @@ func genRouterCode(pkgRealpath string) {
|
|||||||
imports := ""
|
imports := ""
|
||||||
if len(c.ImportComments) > 0 {
|
if len(c.ImportComments) > 0 {
|
||||||
for _, i := range c.ImportComments {
|
for _, i := range c.ImportComments {
|
||||||
|
var s string
|
||||||
if i.ImportAlias != "" {
|
if i.ImportAlias != "" {
|
||||||
imports += fmt.Sprintf(`
|
s = fmt.Sprintf(`
|
||||||
%s "%s"`, i.ImportAlias, i.ImportPath)
|
%s "%s"`, i.ImportAlias, i.ImportPath)
|
||||||
} else {
|
} else {
|
||||||
imports += fmt.Sprintf(`
|
s = fmt.Sprintf(`
|
||||||
"%s"`, i.ImportPath)
|
"%s"`, i.ImportPath)
|
||||||
}
|
}
|
||||||
|
if !strings.Contains(globalimport, s) {
|
||||||
|
imports += s
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +494,7 @@ func genRouterCode(pkgRealpath string) {
|
|||||||
}`, filters)
|
}`, filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
globalimport = imports
|
globalimport += imports
|
||||||
|
|
||||||
globalinfo = globalinfo + `
|
globalinfo = globalinfo + `
|
||||||
beego.GlobalControllerRouter["` + k + `"] = append(beego.GlobalControllerRouter["` + k + `"],
|
beego.GlobalControllerRouter["` + k + `"] = append(beego.GlobalControllerRouter["` + k + `"],
|
||||||
|
Loading…
Reference in New Issue
Block a user