Skip to content

Commit

Permalink
feat: strconv: add JoinBytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Nov 23, 2024
1 parent 94f6b35 commit f119405
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions strconv/strconvutil/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ func SliceItoaMore[S ~[]E, E constraints.Integer](s S, dedupe, sort bool) []stri
}
return out
}

// JoinBytes joins a slice of strings and returns a byte array.
func JoinBytes(data []string, sep []byte) []byte {
var out []byte
for i, r := range data {
out = append(out, []byte(r)...)
if len(sep) > 0 && i < len(data)-1 {
out = append(out, sep...)
}
}
return out
}

0 comments on commit f119405

Please sign in to comment.