mirror of
https://github.com/beego/bee.git
synced 2025-07-05 08:00:18 +00:00
bug fixed
This commit is contained in:
17
fix.go
17
fix.go
@ -220,6 +220,11 @@ func fixFile(file string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fixLogModule(fixed string) string {
|
func fixLogModule(fixed string) string {
|
||||||
|
const gitHubBeego = `"github.com/astaxie/beego"` + "\n"
|
||||||
|
const gitHubLogs = `"github.com/astaxie/beego/logs"` + "\n"
|
||||||
|
if strings.Contains(fixed, gitHubLogs) {
|
||||||
|
return fixed
|
||||||
|
}
|
||||||
logReplacer := []string{
|
logReplacer := []string{
|
||||||
"beego.LevelEmergency", "logs.LevelEmergency",
|
"beego.LevelEmergency", "logs.LevelEmergency",
|
||||||
"beego.LevelAlert", "logs.LevelAlert",
|
"beego.LevelAlert", "logs.LevelAlert",
|
||||||
@ -279,20 +284,22 @@ func fixLogModule(fixed string) string {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const gitHubBeego = `"github.com/astaxie/beego"` + "\n"
|
|
||||||
const gitHubLogs = `"github.com/astaxie/beego/logs"` + "\n"
|
|
||||||
if !needBeego {
|
if !needBeego {
|
||||||
return strings.Replace(fixed, gitHubBeego, gitHubLogs, -1)
|
return strings.Replace(fixed, gitHubBeego, gitHubLogs, -1)
|
||||||
}
|
}
|
||||||
slash = false
|
slash = false
|
||||||
newFixed := ""
|
newFixed := ""
|
||||||
startImport := false
|
startImport := false
|
||||||
|
inserted := false
|
||||||
lines := strings.Split(fixed, "\n")
|
lines := strings.Split(fixed, "\n")
|
||||||
for num, line := range lines {
|
for num, line := range lines {
|
||||||
if num == len(lines)-1 && (line == "" || line == "\n") {
|
if num == len(lines)-1 && (line == "" || line == "\n") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newFixed += line + "\n"
|
newFixed += line + "\n"
|
||||||
|
if inserted {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if strings.HasPrefix(line, "import") {
|
if strings.HasPrefix(line, "import") {
|
||||||
if strings.HasPrefix(line, "import (") {
|
if strings.HasPrefix(line, "import (") {
|
||||||
slash = true
|
slash = true
|
||||||
@ -300,12 +307,14 @@ func fixLogModule(fixed string) string {
|
|||||||
} else {
|
} else {
|
||||||
if strings.Contains(line, gitHubBeego) {
|
if strings.Contains(line, gitHubBeego) {
|
||||||
newFixed += `import "github.com/astaxie/beego/logs"` + "\n"
|
newFixed += `import "github.com/astaxie/beego/logs"` + "\n"
|
||||||
|
inserted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !startImport {
|
if !startImport {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if slash {
|
if slash {
|
||||||
if strings.Contains(line, ")") {
|
if strings.Contains(line, ")") {
|
||||||
slash = false
|
slash = false
|
||||||
@ -319,12 +328,16 @@ func fixLogModule(fixed string) string {
|
|||||||
|
|
||||||
if strings.Compare(l1, gitHubLogs) > 0 {
|
if strings.Compare(l1, gitHubLogs) > 0 {
|
||||||
newFixed += fmt.Sprintf("\t" + `"github.com/astaxie/beego/logs"` + "\n")
|
newFixed += fmt.Sprintf("\t" + `"github.com/astaxie/beego/logs"` + "\n")
|
||||||
|
inserted = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Compare(l1, gitHubLogs) < 0 && strings.Compare(l2, gitHubLogs) > 0 {
|
if strings.Compare(l1, gitHubLogs) < 0 && strings.Compare(l2, gitHubLogs) > 0 {
|
||||||
newFixed += fmt.Sprintf("\t" + `"github.com/astaxie/beego/logs"` + "\n")
|
newFixed += fmt.Sprintf("\t" + `"github.com/astaxie/beego/logs"` + "\n")
|
||||||
|
inserted = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
startImport = strings.HasPrefix(line, "import")
|
startImport = strings.HasPrefix(line, "import")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user