gocommon/convert/convert.go
Matthieu 'JP' DERASSE 5591da9c47
Some checks failed
continuous-integration/drone/push Build is failing
feat(log): Working on log library
2022-11-28 22:06:42 +00:00

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
}