v0.0.606 add .DataMeta() to enums
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m18s

This commit is contained in:
2025-10-04 00:08:32 +02:00
parent 2cf571579b
commit 039a53a395
5 changed files with 52 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
package enums
import "encoding/json"
type Enum interface {
Valid() bool
ValuesAny() []any
@@ -31,3 +33,25 @@ type EnumDescriptionMetaValue struct {
Value Enum `json:"value"`
Description string `json:"description"`
}
type EnumMetaDataValue struct {
VarName string `json:"varName"`
Value Enum `json:"value"`
Description *string `json:"description"`
Data map[string]any `json:"-"` //handled by MarshalJSON
}
func (v EnumMetaDataValue) MarshalJSON() ([]byte, error) {
m := make(map[string]any, 8)
for k, dv := range v.Data {
m[k] = dv
}
m["varName"] = v.VarName
m["value"] = v.Value
m["description"] = v.Description
return json.Marshal(m)
}