mirror of
https://github.com/moby/moby.git
synced 2026-08-05 23:51:18 +00:00
17 lines
461 B
Go
17 lines
461 B
Go
package rulesfn
|
|
|
|
import "strings"
|
|
|
|
// Split splits the input string by the delimiter and returns the resulting
|
|
// parts. If limit is > 0, at most limit substrings are returned.
|
|
// Returns a slice with a single empty string if the input is empty.
|
|
func Split(input, delimiter string, limit int) []string {
|
|
if len(input) == 0 {
|
|
return []string{""}
|
|
}
|
|
if limit > 0 {
|
|
return strings.SplitN(input, delimiter, limit)
|
|
}
|
|
return strings.Split(input, delimiter)
|
|
}
|