From addcc14987f3d05577a07240b1451c79e7f4f91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Schmitz?= <152157960+bahkauv70@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:45:25 +0100 Subject: [PATCH] fix: remove special handling for format tag in enums that lead to broken code --- templates/go/model_enum.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/go/model_enum.mustache b/templates/go/model_enum.mustache index 524701c..a5c8f93 100644 --- a/templates/go/model_enum.mustache +++ b/templates/go/model_enum.mustache @@ -1,5 +1,5 @@ // {{{classname}}} {{{description}}}{{^description}}the model '{{{classname}}}'{{/description}} -type {{{classname}}} {{{format}}}{{^format}}{{dataType}}{{/format}} +type {{{classname}}} {{dataType}} // List of {{{name}}} const ( @@ -22,7 +22,7 @@ var Allowed{{{classname}}}EnumValues = []{{{classname}}}{ } func (v *{{{classname}}}) UnmarshalJSON(src []byte) error { - var value {{{format}}}{{^format}}{{dataType}}{{/format}} + var value {{dataType}} err := json.Unmarshal(src, &value) if err != nil { return err @@ -45,7 +45,7 @@ func (v *{{{classname}}}) UnmarshalJSON(src []byte) error { // New{{{classname}}}FromValue returns a pointer to a valid {{{classname}}} // for the value passed as argument, or an error if the value passed is not allowed by the enum -func New{{{classname}}}FromValue(v {{{format}}}{{^format}}{{dataType}}{{/format}}) (*{{{classname}}}, error) { +func New{{{classname}}}FromValue(v {{dataType}}) (*{{{classname}}}, error) { ev := {{{classname}}}(v) if ev.IsValid() { return &ev, nil