feat: add export library

This commit is contained in:
Samuel N Cui
2023-10-06 09:04:10 +08:00
parent b7c075b8a5
commit 030a6d9516
7 changed files with 152 additions and 28 deletions

View File

@@ -104,3 +104,13 @@ func Value(src proto.Message) (driver.Value, error) {
return buf, nil
}
func ToEnum[T ~int32](pbmap map[string]int32, default_ T) func(str string) T {
return func(str string) T {
v, ok := pbmap[string(str)]
if !ok {
return default_
}
return T(v)
}
}