Skip to content

Commit

Permalink
Merge pull request #700 from NAICNO/larstha-699-split
Browse files Browse the repository at this point in the history
Fix #699 - vet uses of strings.Split
  • Loading branch information
lars-t-hansen authored Nov 21, 2024
2 parents 7a91fbb + 0a91e35 commit bb1995d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion code/sonalyze/cmd/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func (rs *RepeatableCommaSeparated[T]) String() string {
}

func (rs *RepeatableCommaSeparated[T]) Set(s string) error {
ys := strings.Split(s, ",")
ys := strings.Split(s, ",") // OK: "" is ruled out below
ws := make([]T, 0, len(ys))
for _, y := range ys {
if y == "" {
Expand Down
6 changes: 4 additions & 2 deletions code/sonalyze/table/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ func ParseFormatSpec(
if fmtOpt == "help" {
others["help"] = true
}
for _, fieldName := range strings.Split(spec, ",") {
fields, _ = addField(fieldName, fields, others, formatters, aliases)
if spec != "" {
for _, fieldName := range strings.Split(spec, ",") {
fields, _ = addField(fieldName, fields, others, formatters, aliases)
}
}
return fields, others, nil
}
Expand Down

0 comments on commit bb1995d

Please sign in to comment.