You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
342 B
Go
15 lines
342 B
Go
package utils
|
|
|
|
import "errors"
|
|
|
|
func GetEvent[T interface{}](eventObj []interface{}) (*T, error) {
|
|
if len(eventObj) == 0 || eventObj[0] == nil {
|
|
return nil, errors.New("cannot get event from eventObj")
|
|
}
|
|
if event, ok := eventObj[0].(*T); ok {
|
|
return event, nil
|
|
} else {
|
|
return nil, errors.New("cannot get event from eventObj")
|
|
}
|
|
}
|