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:
@@ -117,6 +117,20 @@ func (e {{.EnumTypeName}}) DescriptionMeta() enums.EnumDescriptionMetaValue {
|
||||
}
|
||||
{{end}}
|
||||
|
||||
{{if $hasData}}
|
||||
func (e {{.EnumTypeName}}) DataMeta() enums.EnumMetaDataValue {
|
||||
return enums.EnumMetaDataValue{
|
||||
VarName: e.VarName(),
|
||||
Value: e,
|
||||
Description: e.Description(),
|
||||
Data: map[string]any{
|
||||
{{ range $datakey, $datatype := $enumdef | generalDataKeys }} "{{ $datakey }}": e.Data().{{ $datakey | godatakey }},
|
||||
{{ end }}
|
||||
},
|
||||
}
|
||||
}
|
||||
{{end}}
|
||||
|
||||
func Parse{{.EnumTypeName}}(vv string) ({{.EnumTypeName}}, bool) {
|
||||
for _, ev := range __{{.EnumTypeName}}Values {
|
||||
if string(ev) == vv {
|
||||
@@ -136,6 +150,12 @@ func {{.EnumTypeName}}ValuesMeta() []enums.EnumMetaValue {
|
||||
}
|
||||
}
|
||||
|
||||
func {{.EnumTypeName}}ValuesDataMeta() []enums.EnumMetaValue {
|
||||
return []enums.EnumDataMetaValue{ {{range .Values}}
|
||||
{{.VarName}}.DataMeta(), {{end}}
|
||||
}
|
||||
}
|
||||
|
||||
{{if $hasDescr}}
|
||||
func {{.EnumTypeName}}ValuesDescriptionMeta() []enums.EnumDescriptionMetaValue {
|
||||
return []enums.EnumDescriptionMetaValue{ {{range .Values}}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
4
go.mod
4
go.mod
@@ -48,7 +48,7 @@ require (
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/quic-go/qpack v0.5.1 // indirect
|
||||
github.com/quic-go/quic-go v0.54.1 // indirect
|
||||
github.com/quic-go/quic-go v0.55.0 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||
@@ -62,7 +62,7 @@ require (
|
||||
golang.org/x/mod v0.28.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
golang.org/x/tools v0.37.0 // indirect
|
||||
google.golang.org/protobuf v1.36.9 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/libc v1.37.6 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@@ -185,6 +185,8 @@ github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQB
|
||||
github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
|
||||
github.com/quic-go/quic-go v0.54.1 h1:4ZAWm0AhCb6+hE+l5Q1NAL0iRn/ZrMwqHRGQiFwj2eg=
|
||||
github.com/quic-go/quic-go v0.54.1/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
|
||||
github.com/quic-go/quic-go v0.55.0 h1:zccPQIqYCXDt5NmcEabyYvOnomjs8Tlwl7tISjJh9Mk=
|
||||
github.com/quic-go/quic-go v0.55.0/go.mod h1:DR51ilwU1uE164KuWXhinFcKWGlEjzys2l8zUl5Ss1U=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
@@ -477,6 +479,8 @@ google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyM
|
||||
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@@ -1,5 +1,5 @@
|
||||
package goext
|
||||
|
||||
const GoextVersion = "0.0.605"
|
||||
const GoextVersion = "0.0.606"
|
||||
|
||||
const GoextVersionTimestamp = "2025-09-29T16:39:16+0200"
|
||||
const GoextVersionTimestamp = "2025-10-04T00:08:32+0200"
|
||||
|
Reference in New Issue
Block a user