* chore(deps): bump filippo.io/edwards25519 from 1.1.0 to 1.1.1 * chore(deps): bump github.com/cloudflare/circl from 1.6.1 to 1.6.3 * chore(deps): bump github.com/russellhaering/goxmldsig from 1.5.0 to 1.6.0 * build(deps): bump fpicalausa/remove-stale-branches from 2.4.0 to 2.6.1 * build(deps): bump actions/upload-artifact from 4.6.2 to 7.0.1 * build(deps): bump actions/download-artifact from 4.3.0 to 8.0.1 * build(deps): bump pnpm/action-setup from 5.0.0 to 6.0.8 * chore(deps): bump github.com/shamaton/msgpack/v2 to v2.4.1 and reva to v2.0.0-20260519092700-9da01c6fb954 * chore: regenerate lock fil s and vendor * chore: changelog * fix: bump golang.org/x/image to v0.39.0 (GO-2026-4815, GO-2026-4961, GO-2026-4962)
44 lines
832 B
Go
44 lines
832 B
Go
package common
|
|
|
|
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) (public, omit bool, name string) {
|
|
// A to Z
|
|
if !c.isPublic(field.Name) {
|
|
return false, 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 {
|
|
return 0x41 <= name[0] && name[0] <= 0x5a
|
|
}
|