mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:21:02 +00:00
Fixed error in window os
This commit is contained in:
parent
3c8ed9adfc
commit
7ceff43db6
15
parser.go
15
parser.go
@ -23,7 +23,6 @@ import (
|
|||||||
"go/token"
|
"go/token"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -58,7 +57,8 @@ func init() {
|
|||||||
|
|
||||||
func parserPkg(pkgRealpath, pkgpath string) error {
|
func parserPkg(pkgRealpath, pkgpath string) error {
|
||||||
rep := strings.NewReplacer("\\", "_", "/", "_", ".", "_")
|
rep := strings.NewReplacer("\\", "_", "/", "_", ".", "_")
|
||||||
commentFilename = coomentPrefix + rep.Replace(strings.Replace(pkgRealpath, AppPath, "", -1)) + ".go"
|
commentFilename, _ = filepath.Rel(AppPath, pkgRealpath)
|
||||||
|
commentFilename = coomentPrefix + rep.Replace(commentFilename) + ".go"
|
||||||
if !compareFile(pkgRealpath) {
|
if !compareFile(pkgRealpath) {
|
||||||
logs.Info(pkgRealpath + " no changed")
|
logs.Info(pkgRealpath + " no changed")
|
||||||
return nil
|
return nil
|
||||||
@ -174,7 +174,7 @@ func genRouterCode(pkgRealpath string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if globalinfo != "" {
|
if globalinfo != "" {
|
||||||
f, err := os.Create(path.Join(getRouterDir(pkgRealpath), commentFilename))
|
f, err := os.Create(filepath.Join(getRouterDir(pkgRealpath), commentFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ func genRouterCode(pkgRealpath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareFile(pkgRealpath string) bool {
|
func compareFile(pkgRealpath string) bool {
|
||||||
if !utils.FileExists(path.Join(getRouterDir(pkgRealpath), commentFilename)) {
|
if !utils.FileExists(filepath.Join(getRouterDir(pkgRealpath), commentFilename)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if utils.FileExists(lastupdateFilename) {
|
if utils.FileExists(lastupdateFilename) {
|
||||||
@ -235,11 +235,12 @@ func getpathTime(pkgRealpath string) (lastupdate int64, err error) {
|
|||||||
func getRouterDir(pkgRealpath string) string {
|
func getRouterDir(pkgRealpath string) string {
|
||||||
dir := filepath.Dir(pkgRealpath)
|
dir := filepath.Dir(pkgRealpath)
|
||||||
for {
|
for {
|
||||||
d := path.Join(dir, "routers")
|
d := filepath.Join(dir, "routers")
|
||||||
if dir == AppPath {
|
if utils.FileExists(d) {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
if utils.FileExists(d) {
|
|
||||||
|
if r, _ := filepath.Rel(dir, AppPath); r == "." {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
// Parent dir.
|
// Parent dir.
|
||||||
|
Loading…
Reference in New Issue
Block a user