v0.0.606 add .DataMeta()
to enums
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m18s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m18s
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user