anilist/utils.go

25 lines
476 B
Go
Raw 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) {
if value != nil && len(value) > 0 {
m[key] = value
}
}