pkg: Move camel_to_dashed from util/ to strutil/.

This commit is contained in:
Qi Xiao 2020-09-03 05:10:59 +01:00
parent ee62608e88
commit eae14f91b9
4 changed files with 7 additions and 7 deletions

View File

@ -6,7 +6,7 @@ import (
"github.com/elves/elvish/pkg/eval/vals"
"github.com/elves/elvish/pkg/parse"
"github.com/elves/elvish/pkg/util"
"github.com/elves/elvish/pkg/strutil"
)
// RawOptions is the type of an argument a Go-native function can take to
@ -36,7 +36,7 @@ func scanOptions(rawOpts RawOptions, ptr interface{}) error {
f := struc.Type().Field(i)
optName := f.Tag.Get("name")
if optName == "" {
optName = util.CamelToDashed(f.Name)
optName = strutil.CamelToDashed(f.Name)
}
fieldIdxForOpt[optName] = i
}

View File

@ -4,7 +4,7 @@ import (
"reflect"
"sync"
"github.com/elves/elvish/pkg/util"
"github.com/elves/elvish/pkg/strutil"
)
// StructMap may be implemented by a struct to mark the struct as a "struct
@ -70,7 +70,7 @@ func makeStructMapInfo(t reflect.Type) structMapInfo {
for i := 0; i < n; i++ {
field := t.Field(i)
if field.PkgPath == "" && !field.Anonymous {
fieldNames[i] = util.CamelToDashed(field.Name)
fieldNames[i] = strutil.CamelToDashed(field.Name)
filledFields++
}
}
@ -78,7 +78,7 @@ func makeStructMapInfo(t reflect.Type) structMapInfo {
for i := 0; i < m; i++ {
method := t.Method(i)
if method.PkgPath == "" && method.Type.NumIn() == 1 && method.Type.NumOut() == 1 {
fieldNames[i+n] = util.CamelToDashed(method.Name)
fieldNames[i+n] = strutil.CamelToDashed(method.Name)
filledFields++
}
}

View File

@ -1,4 +1,4 @@
package util
package strutil
import (
"bytes"

View File

@ -1,4 +1,4 @@
package util
package strutil
import "testing"