tpl: Improve template funcs GoDoc

This commit is contained in:
Bjørn Erik Pedersen
2022-12-21 13:11:08 +01:00
parent aa2c724195
commit cd1ed563a8
17 changed files with 170 additions and 163 deletions

View File

@@ -25,13 +25,13 @@ import (
"github.com/spf13/cast"
)
// Sort returns a sorted sequence.
func (ns *Namespace) Sort(seq any, args ...any) (any, error) {
if seq == nil {
// Sort returns a sorted copy of the list l.
func (ns *Namespace) Sort(l any, args ...any) (any, error) {
if l == nil {
return nil, errors.New("sequence must be provided")
}
seqv, isNil := indirect(reflect.ValueOf(seq))
seqv, isNil := indirect(reflect.ValueOf(l))
if isNil {
return nil, errors.New("can't iterate over a nil value")
}
@@ -43,7 +43,7 @@ func (ns *Namespace) Sort(seq any, args ...any) (any, error) {
case reflect.Map:
sliceType = reflect.SliceOf(seqv.Type().Elem())
default:
return nil, errors.New("can't sort " + reflect.ValueOf(seq).Type().String())
return nil, errors.New("can't sort " + reflect.ValueOf(l).Type().String())
}
collator := langs.GetCollator(ns.deps.Language)