1
0
mirror of https://github.com/divan/expvarmon.git synced 2025-04-25 13:48:54 +08:00
expvarmon/ports.go
2015-04-21 12:51:01 +03:00

17 lines
322 B
Go

package main
import (
"errors"
"strings"
)
// ParsePorts converts comma-separated ports into strings slice
func ParsePorts(s string) ([]string, error) {
ports := strings.FieldsFunc(s, func(r rune) bool { return r == ',' })
if len(ports) == 0 {
return nil, errors.New("no ports specified")
}
return ports, nil
}