Skip to content

Commit

Permalink
all: Use strings.Cut
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Mar 17, 2022
1 parent 423594e commit d57df36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func SetEnvVars(oldVars *[]string, keyValues ...string) {
}

func SplitEnvVar(v string) (string, string) {
parts := strings.SplitN(v, "=", 2)
return parts[0], parts[1]
name, value, _ := strings.Cut(v, "=")
return name, value
}

func setEnvVar(vars *[]string, key, value string) {
Expand Down
6 changes: 3 additions & 3 deletions tpl/collections/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ func (ns *Namespace) lookupFunc(fname string) (reflect.Value, bool) {
return templ.GetFunc(fname)
}

ss := strings.SplitN(fname, ".", 2)
namespace, name, _ := strings.Cut(fname, ".")

// Namespace
nv, found := ns.lookupFunc(ss[0])
nv, found := ns.lookupFunc(namespace)
if !found {
return reflect.Value{}, false
}
Expand All @@ -131,7 +131,7 @@ func (ns *Namespace) lookupFunc(fname string) (reflect.Value, bool) {
nv = reflect.ValueOf(v)

// method
m := hreflect.GetMethodByName(nv, ss[1])
m := hreflect.GetMethodByName(nv, name)

if m.Kind() == reflect.Invalid {
return reflect.Value{}, false
Expand Down

0 comments on commit d57df36

Please sign in to comment.