Documentation
¶
Index ¶
- func Contains(list []string, element string) bool
- func FindKeyCaseInsensitive(input map[string]string, key string) (string, bool)
- func FindValueCaseInsensitive(input map[string]string, key string) (string, bool)
- func Merge(input1 []string, input2 []string) []string
- func Remove(input map[string]string, key string) map[string]string
- func RemoveSimilar(list []string, element string) []string
- func ToKeyValueMap(input []string, splitBy string) map[string]string
- func ToSlice(input map[string]string, combineBy string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains checks if a given string is in a given list of strings. Returns true if the element was found, false otherwise.
Example:
list := []string{"a", "b", "c"} element := "b" contains := Contains(list, element) // contains is true
func FindKeyCaseInsensitive ¶
This method tries to find the given key is in the map. It searches different cases of the key:
- the exact match
- all lower case letters
- all upper case letters
If the key in any of these versions was found, it'll be returned alongside with a boolean indicating whether or not it was found.
Example:
map := {"a": "b", "c": "d"} key := "A" key, found = FindKeyCaseInsensitive(map, key) // key is "a" and found is true
func FindValueCaseInsensitive ¶
This method tries to find the given key is in the map and return its value. It searches different cases of the key:
- the exact match
- all lower case letters
- all upper case letters
If the key in any of these versions was found, its value will be returned alongside with a boolean indicating whether or not it was found.
Example:
map := {"a": "b", "c": "d"} key := "A" value, found = FindValueCaseInsensitive(map, key) // value is "b" and found is true
func Merge ¶
Merge merges two lists of strings and returns the result. The result will contain all elements from the first list and all elements from the second list which are not already in the first list.
Example:
list1 := []string{"a", "b", "c"} list2 := []string{"b", "c", "d"} mergedList := Merge(list1, list2) // mergedList is ["a", "b", "c", "d"]
func Remove ¶
Removes a given key from the input map and uses FindKeyCaseInsensitive() for this. The resulting map is being returned. If the key was not found, the input map will be returned.
Example:
map := {"a": "b", "c": "d"} key := "A" map = Remove(map, key) // map is {"c": "d"}
func RemoveSimilar ¶
RemoveSimilar removes all elements from the list which contain the given element. Returns the filtered list.
Example:
list := []string{"a", "b", "c"} element := "b" filteredList := RemoveSimilar(list, element) // filteredList is ["a", "c"]
func ToKeyValueMap ¶
ToKeyValueMap converts a list of strings to a map of strings. The input list will be converted based on the delimiter, 'splitBy'. The resulting map will contain the keys and values of the input list.
Example:
list := []string{"a=b", "c=d"} splitBy := "=" keyValueMap := ToKeyValueMap(list, splitBy) // keyValueMap is {"a": "b", "c": "d"}
func ToSlice ¶
ToSlice converts a map of strings to a list of strings. The keys and values will be combined by the given delimiter, 'combineBy'. The resulting list will contain the keys and values of the input map.
Example:
map := {"a": "b", "c": "d"} combineBy := "=" slice := ToSlice(map, combineBy) // slice is ["a=b", "c=d"]
Types ¶
This section is empty.