anilist/utils.go

25 lines
460 B
Go
Raw Permalink Normal View History

2022-02-03 17:23:29 +01:00
package anilist
import (
"reflect"
"time"
)
func addValue2InterfaceMap[K, T comparable](m map[K]interface{}, key K, value T) {
if value != *new(T) {
if reflect.TypeOf(new(T)).Elem() == reflect.TypeOf(new(time.Time)).Elem() {
var t interface{} = value
m[key] = t.(time.Time).Unix()
return
}
m[key] = value
}
}
func addSlice2InterfaceMap[K, T comparable](m map[K]interface{}, key K, value []T) {
2023-10-09 13:49:37 +02:00
if len(value) > 0 {
2022-02-03 17:23:29 +01:00
m[key] = value
}
}