Skip to content

Commit

Permalink
Merge pull request #37 from keisku/go-issue-67149
Browse files Browse the repository at this point in the history
Use `strings.TrimPrefix()` instead of `strings.TrimLeft()`
  • Loading branch information
keisku authored May 3, 2024
2 parents 77b0ae2 + 8278f65 commit abae61c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions explore/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ func (o *Options) Complete(f cmdutil.Factory, args []string) error {
var re string
if strings.HasPrefix(o.inputFieldPath, gotGVR.Resource) {
// E.g., "nodes.*spec" -> ".*spec"
re = strings.TrimLeft(o.inputFieldPath, gotGVR.Resource)
re = strings.TrimPrefix(o.inputFieldPath, gotGVR.Resource)
} else if strings.HasPrefix(o.inputFieldPath, singularResource(gotGVR.Resource)) {
// E.g., "node.*spec" -> ".*spec"
re = strings.TrimLeft(o.inputFieldPath, singularResource(gotGVR.Resource))
re = strings.TrimPrefix(o.inputFieldPath, singularResource(gotGVR.Resource))
} else {
// E.g., "no.*spec" -> ".*spec"
left := o.inputFieldPath[:idx]
re = strings.TrimLeft(o.inputFieldPath, left)
prefix := o.inputFieldPath[:idx]
re = strings.TrimPrefix(o.inputFieldPath, prefix)
}
o.inputFieldPathRegex, err = regexp.Compile(re)
if err != nil {
Expand Down

0 comments on commit abae61c

Please sign in to comment.