bump reva

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2025-09-12 12:18:47 +02:00
parent 9f096d4107
commit f8440edc9a
66 changed files with 3771 additions and 1136 deletions
+29 -10
View File
@@ -1,23 +1,42 @@
package common
import "reflect"
import (
"reflect"
"strings"
)
// Common is used encoding/decoding
type Common struct {
}
// CheckField returns flag whether should encode/decode or not and field name
func (c *Common) CheckField(field reflect.StructField) (bool, string) {
func (c *Common) CheckField(field reflect.StructField) (public, omit bool, name string) {
// A to Z
if c.isPublic(field.Name) {
if tag := field.Tag.Get("msgpack"); tag == "-" {
return false, ""
} else if len(tag) > 0 {
return true, tag
}
return true, field.Name
if !c.isPublic(field.Name) {
return false, false, ""
}
return false, ""
tag := field.Tag.Get("msgpack")
if tag == "" {
return true, false, field.Name
}
parts := strings.Split(tag, ",")
// check ignore
if parts[0] == "-" {
return false, false, ""
}
// check omitempty
for _, part := range parts[1:] {
if part == "omitempty" {
omit = true
}
}
// check name
name = field.Name
if parts[0] != "" {
name = parts[0]
}
return true, omit, name
}
func (c *Common) isPublic(name string) bool {