blob: d38814b5db4dfa8ff0979b72515fddcce1bacb37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package dmmsg
import (
"fmt"
"reflect"
)
func castValue[T any](obj interface{}) (thing T, err error) {
casted, ok := (obj).(T)
if !ok {
err = fmt.Errorf("%s: required value is not of type \"%v\": %v",
InvalidDanmakuJson, reflect.TypeOf(thing).String(), obj)
return
}
thing = casted
return
}
|