mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 14:50:55 +00:00
staticcheck checks -ST1003 remove
This commit is contained in:
parent
5b42afa324
commit
2a579eb27c
@ -55,7 +55,7 @@ after_script:
|
|||||||
- rm -rf ./res/var/*
|
- rm -rf ./res/var/*
|
||||||
script:
|
script:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
- staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-ST1003,-SA6005,-SA1019"
|
- staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-SA6005,-SA1019"
|
||||||
- unconvert $(go list ./... | grep -v /vendor/)
|
- unconvert $(go list ./... | grep -v /vendor/)
|
||||||
- ineffassign .
|
- ineffassign .
|
||||||
- find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s
|
- find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s
|
||||||
|
18
router.go
18
router.go
@ -513,7 +513,7 @@ func (p *ControllerRegister) URLFor(endpoint string, values ...interface{}) stri
|
|||||||
controllerName := strings.Join(paths[:len(paths)-1], "/")
|
controllerName := strings.Join(paths[:len(paths)-1], "/")
|
||||||
methodName := paths[len(paths)-1]
|
methodName := paths[len(paths)-1]
|
||||||
for m, t := range p.routers {
|
for m, t := range p.routers {
|
||||||
ok, url := p.getUrl(t, "/", controllerName, methodName, params, m)
|
ok, url := p.getURL(t, "/", controllerName, methodName, params, m)
|
||||||
if ok {
|
if ok {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
@ -521,17 +521,17 @@ func (p *ControllerRegister) URLFor(endpoint string, values ...interface{}) stri
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ControllerRegister) getUrl(t *Tree, url, controllerName, methodName string, params map[string]string, httpMethod string) (bool, string) {
|
func (p *ControllerRegister) getURL(t *Tree, url, controllerName, methodName string, params map[string]string, httpMethod string) (bool, string) {
|
||||||
for _, subtree := range t.fixrouters {
|
for _, subtree := range t.fixrouters {
|
||||||
u := path.Join(url, subtree.prefix)
|
u := path.Join(url, subtree.prefix)
|
||||||
ok, u := p.getUrl(subtree, u, controllerName, methodName, params, httpMethod)
|
ok, u := p.getURL(subtree, u, controllerName, methodName, params, httpMethod)
|
||||||
if ok {
|
if ok {
|
||||||
return ok, u
|
return ok, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.wildcard != nil {
|
if t.wildcard != nil {
|
||||||
u := path.Join(url, urlPlaceholder)
|
u := path.Join(url, urlPlaceholder)
|
||||||
ok, u := p.getUrl(t.wildcard, u, controllerName, methodName, params, httpMethod)
|
ok, u := p.getURL(t.wildcard, u, controllerName, methodName, params, httpMethod)
|
||||||
if ok {
|
if ok {
|
||||||
return ok, u
|
return ok, u
|
||||||
}
|
}
|
||||||
@ -599,7 +599,7 @@ func (p *ControllerRegister) getUrl(t *Tree, url, controllerName, methodName str
|
|||||||
}
|
}
|
||||||
var i int
|
var i int
|
||||||
var startReg bool
|
var startReg bool
|
||||||
regUrl := ""
|
regURL := ""
|
||||||
for _, v := range strings.Trim(l.regexps.String(), "^$") {
|
for _, v := range strings.Trim(l.regexps.String(), "^$") {
|
||||||
if v == '(' {
|
if v == '(' {
|
||||||
startReg = true
|
startReg = true
|
||||||
@ -608,17 +608,17 @@ func (p *ControllerRegister) getUrl(t *Tree, url, controllerName, methodName str
|
|||||||
startReg = false
|
startReg = false
|
||||||
if v, ok := params[l.wildcards[i]]; ok {
|
if v, ok := params[l.wildcards[i]]; ok {
|
||||||
delete(params, l.wildcards[i])
|
delete(params, l.wildcards[i])
|
||||||
regUrl = regUrl + v
|
regURL = regURL + v
|
||||||
i++
|
i++
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if !startReg {
|
} else if !startReg {
|
||||||
regUrl = string(append([]rune(regUrl), v))
|
regURL = string(append([]rune(regURL), v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if l.regexps.MatchString(regUrl) {
|
if l.regexps.MatchString(regURL) {
|
||||||
ps := strings.Split(regUrl, "/")
|
ps := strings.Split(regURL, "/")
|
||||||
for _, p := range ps {
|
for _, p := range ps {
|
||||||
url = strings.Replace(url, urlPlaceholder, p, 1)
|
url = strings.Replace(url, urlPlaceholder, p, 1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user