30 lines
442 B
Go
30 lines
442 B
Go
package db
|
|
|
|
import "fmt"
|
|
|
|
func extractCommandID(member interface{}) int {
|
|
switch v := member.(type) {
|
|
case int:
|
|
return v
|
|
case int64:
|
|
return int(v)
|
|
case float64:
|
|
return int(v)
|
|
case string:
|
|
var id int
|
|
fmt.Sscanf(v, "%d", &id)
|
|
return id
|
|
default:
|
|
return 0
|
|
}
|
|
}
|
|
|
|
func splitNotificationKey(key string) []string {
|
|
for i, c := range key {
|
|
if c == ':' {
|
|
return []string{key[:i], key[i+1:]}
|
|
}
|
|
}
|
|
return []string{key, ""}
|
|
}
|