expvarmon/ports.go

17 lines
322 B
Go
Raw Normal View History

2015-04-21 17:51:01 +08:00
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
}