Other: Linter fixes after bumping linter version

This commit is contained in:
James Houlahan
2022-10-11 18:04:39 +02:00
parent 4a5c411665
commit 14a578f319
23 changed files with 273 additions and 206 deletions

View File

@ -1,12 +1,20 @@
package user
import "reflect"
import (
"fmt"
"reflect"
)
func mapTo[From, To any](from []From) []To {
to := make([]To, 0, len(from))
for _, from := range from {
to = append(to, reflect.ValueOf(from).Convert(reflect.TypeOf(to).Elem()).Interface().(To))
val, ok := reflect.ValueOf(from).Convert(reflect.TypeOf(to).Elem()).Interface().(To)
if !ok {
panic(fmt.Sprintf("cannot convert %T to %T", from, *new(To)))
}
to = append(to, val)
}
return to