diff --git a/context/context_go118.go b/context/context_go118.go index b1773520..8ebe8055 100644 --- a/context/context_go118.go +++ b/context/context_go118.go @@ -16,7 +16,7 @@ func init() { } if setting.Key == "vcs.time" { - BuildTime = setting.Key + BuildTime = setting.Value } } } diff --git a/core/router/path.go b/core/router/path.go index 8a6805f3..d4f560fc 100644 --- a/core/router/path.go +++ b/core/router/path.go @@ -43,7 +43,8 @@ func convertMacroTmplToNodePath(tmpl macro.Template) string { // if it has started with {} and it's valid // then the tmpl.Params will be filled, // so no any further check needed. - for _, p := range tmpl.Params { + for i := range tmpl.Params { + p := tmpl.Params[i] if ast.IsTrailing(p.Type) { routePath = strings.Replace(routePath, p.Src, WildcardParam(p.Name), 1) } else { diff --git a/macro/handler/handler.go b/macro/handler/handler.go index 24fc9cfd..b947ca93 100644 --- a/macro/handler/handler.go +++ b/macro/handler/handler.go @@ -36,7 +36,8 @@ func CanMakeHandler(tmpl macro.Template) (needsMacroHandler bool) { // check if we have params like: {name:string} or {name} or {anything:path} without else keyword or any functions used inside these params. // 1. if we don't have, then we don't need to add a handler before the main route's handler (as I said, no performance if macro is not really used) // 2. if we don't have any named params then we don't need a handler too. - for _, p := range tmpl.Params { + for i := range tmpl.Params { + p := tmpl.Params[i] if p.CanEval() { // if at least one needs it, then create the handler. needsMacroHandler = true @@ -85,7 +86,8 @@ func MakeFilter(tmpl macro.Template) context.Filter { } return func(ctx *context.Context) bool { - for _, p := range tmpl.Params { + for i := range tmpl.Params { + p := tmpl.Params[i] if !p.CanEval() { continue // allow. }