Skip to content

Commit

Permalink
add code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajnasz committed Apr 15, 2022
1 parent 605f4c2 commit 95bf65e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions providerlist/providerlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
6 changes: 6 additions & 0 deletions stringutils/stringutils.go
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand All @@ -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)

Expand All @@ -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)

Expand Down

0 comments on commit 95bf65e

Please sign in to comment.