Documentation
¶
Index ¶
- func FieldValueExists[T comparable](v interface{}, name string, expectedValue T) bool
- func IsInSlice(slice []string, match string) bool
- func MapToList[T1 comparable, T2 any](m map[T1]T2) []T2
- func Must[T any](a T, err error) T
- func RemoveDuplicateFromSlice[T string | int](sliceList []T) []T
- func ToPointer[T any](t T) *T
- func ToValue[T any](t *T) T
- func UpperFirstLetter(str string) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldValueExists ¶
func FieldValueExists[T comparable](v interface{}, name string, expectedValue T) bool
FieldValueExists uses reflection to check if any fields with the given name have the given value The is heavily adapted from https://stackoverflow.com/a/38407429
func MapToList ¶
func MapToList[T1 comparable, T2 any](m map[T1]T2) []T2
MapToList will change a map to a list.
func Must ¶
Must panics if the passed error is not nil
The purpose of this function is ignoring error checking when writing tests and only tests. This should not be used on production code.
Example (WithError) ¶
// Following line will panic as there is an error
Must("abc", errors.New("an error"))
Example (WithNoError) ¶
// Following line will not panic as there is no error
result := Must("abc", nil)
// Should print "abc"
fmt.Println(result)
func RemoveDuplicateFromSlice ¶
RemoveDuplicateFromSlice removes duplicate values from a slice.
func UpperFirstLetter ¶
UpperFirstLetter returns the given string with the first letter in uppercase.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.