diff --git a/providerlist/providerlist.go b/providerlist/providerlist.go index fdc600a..37dfc21 100644 --- a/providerlist/providerlist.go +++ b/providerlist/providerlist.go @@ -119,6 +119,7 @@ func getProvidersFromStdinChan() (chan string, error) { return text, nil } +// GetProvidersChan returns a channel which will emit available providers func GetProvidersChan(fn string) (chan string, error) { var lines chan string var err error @@ -140,6 +141,7 @@ func GetProvidersChan(fn string) (chan string, error) { return noComment, nil } +// GetAddresses will split the comma separated addresses by the comma and return them as a slice func GetAddresses(addresses string) []string { return stringutils.Filter(strings.Split(addresses, ","), negate(isEmptyString)) } diff --git a/stringutils/stringutils.go b/stringutils/stringutils.go index dadc37e..a381ff5 100644 --- a/stringutils/stringutils.go +++ b/stringutils/stringutils.go @@ -1,5 +1,7 @@ package stringutils +// Filter filters the slice of string by the given test func and keeps only +// those entries where the test returned true func Filter(lines []string, test func(string) bool) []string { var out []string @@ -12,6 +14,7 @@ func Filter(lines []string, test func(string) bool) []string { return out } +// Map returns the output conv function which executed on all entires func Map(lines []string, conv func(string) string) []string { var out []string @@ -22,6 +25,7 @@ func Map(lines []string, conv func(string) string) []string { return out } +// MapChan enables to alter the input strings and emit them from a channel func MapChan(conv func(string) string, lines chan string) chan string { out := make(chan string) @@ -35,6 +39,8 @@ func MapChan(conv func(string) string, lines chan string) chan string { return out } +// FilterChan reads items from a string channel, and emits only those where the +// test function returned true func FilterChan(test func(string) bool, lines chan string) chan string { out := make(chan string)