mirror of
https://github.com/go-gitea/gitea
synced 2025-07-26 04:08:35 +00:00
Run gopls modernize
on codebase (#34751)
Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func tokens(s string) (a []any) {
|
||||
for _, v := range strings.Fields(s) {
|
||||
for v := range strings.FieldsSeq(s) {
|
||||
a = append(a, v)
|
||||
}
|
||||
return a
|
||||
|
@@ -251,7 +251,7 @@ func extractErrorLine(code []byte, lineNum, posNum int, target string) string {
|
||||
b := bufio.NewReader(bytes.NewReader(code))
|
||||
var line []byte
|
||||
var err error
|
||||
for i := 0; i < lineNum; i++ {
|
||||
for i := range lineNum {
|
||||
if line, err = b.ReadBytes('\n'); err != nil {
|
||||
if i == lineNum-1 && errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
"maps"
|
||||
"reflect"
|
||||
"sync"
|
||||
texttemplate "text/template"
|
||||
@@ -40,9 +41,7 @@ func (t *ScopedTemplate) Funcs(funcMap template.FuncMap) {
|
||||
panic("cannot add new functions to frozen template set")
|
||||
}
|
||||
t.all.Funcs(funcMap)
|
||||
for k, v := range funcMap {
|
||||
t.parseFuncs[k] = v
|
||||
}
|
||||
maps.Copy(t.parseFuncs, funcMap)
|
||||
}
|
||||
|
||||
func (t *ScopedTemplate) New(name string) *template.Template {
|
||||
@@ -159,9 +158,7 @@ func newScopedTemplateSet(all *template.Template, name string) (*scopedTemplateS
|
||||
|
||||
textTmplPtr.muFuncs.Lock()
|
||||
ts.execFuncs = map[string]reflect.Value{}
|
||||
for k, v := range textTmplPtr.execFuncs {
|
||||
ts.execFuncs[k] = v
|
||||
}
|
||||
maps.Copy(ts.execFuncs, textTmplPtr.execFuncs)
|
||||
textTmplPtr.muFuncs.Unlock()
|
||||
|
||||
var collectTemplates func(nodes []parse.Node)
|
||||
@@ -220,9 +217,7 @@ func (ts *scopedTemplateSet) newExecutor(funcMap map[string]any) TemplateExecuto
|
||||
tmpl := texttemplate.New("")
|
||||
tmplPtr := ptr[textTemplate](tmpl)
|
||||
tmplPtr.execFuncs = map[string]reflect.Value{}
|
||||
for k, v := range ts.execFuncs {
|
||||
tmplPtr.execFuncs[k] = v
|
||||
}
|
||||
maps.Copy(tmplPtr.execFuncs, ts.execFuncs)
|
||||
if funcMap != nil {
|
||||
tmpl.Funcs(funcMap)
|
||||
}
|
||||
|
Reference in New Issue
Block a user