21 lines
507 B
Go
21 lines
507 B
Go
package convert
|
|
|
|
// ToPointer will convert any type of data to his pointer.
|
|
func ToPointer[T any](v T) *T {
|
|
return &v
|
|
}
|
|
|
|
// Stringer is a interface that any "enum" style struct need to follow.
|
|
type Stringer interface {
|
|
String() string
|
|
}
|
|
|
|
// StringerSliceToStringSlice will take a slice of stringer and convert it to a slice of string.
|
|
func StringerSliceToStringSlice[E Stringer](v []E) []string {
|
|
output := make([]string, len(v))
|
|
for i, data := range v {
|
|
output[i] = data.String()
|
|
}
|
|
return output
|
|
}
|