diff --git a/conv/conv.go b/conv/conv.go index 892eb02..fabfe46 100644 --- a/conv/conv.go +++ b/conv/conv.go @@ -15,6 +15,8 @@ func String(val any) string { return fmt.Sprintf("%d", val) case float32, float64: return fmt.Sprintf("%f", val) + case []byte: + return string(val) case string: return val case nil: diff --git a/slices/slices.go b/slices/slices.go index d7a29b1..86ec913 100644 --- a/slices/slices.go +++ b/slices/slices.go @@ -156,3 +156,18 @@ func Size[T any](size int, slice ...T) bool { func Append[T any](slice []T, elements ...T) []T { return append(slice, elements...) } + +// Len returns the length of a slice. +func Len[T any](slice []T) int { + return len(slice) +} + +// Reverse reverses the order of elements in a slice. +func Reverse[T any](slice []T) []T { + for i := len(slice)/2 - 1; i >= 0; i-- { + opp := len(slice) - 1 - i + slice[i], slice[opp] = slice[opp], slice[i] + } + + return slice +}