-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
35 changed files
with
1,057 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
// Code generated by go-enum-encoding DO NOT EDIT | ||
// Code generated by go-enum-encoding DO NOT EDIT. | ||
|
||
package {{.Package}} | ||
|
||
import "errors" | ||
|
||
var ErrUnknown{{.Type}} = errors.New("unknown {{.Type}}") | ||
|
||
var vals_{{.Type}} = map[{{.Type}}][]byte{ | ||
{{.val_to_json}} | ||
var value_to_bytes_{{.Type}} = map[{{.Type}}][]byte{ | ||
{{.value_to_bytes}} | ||
} | ||
|
||
var vals_inv_{{.Type}} = map[string]{{.Type}}{ | ||
{{.json_to_value}} | ||
var string_to_value_{{.Type}} = map[string]{{.Type}}{ | ||
{{.string_to_value}} | ||
} | ||
|
||
func (s *{{.Type}}) UnmarshalText(text []byte) error { | ||
var ok bool | ||
if *s, ok = vals_inv_{{.Type}}[string(text)]; !ok { | ||
if *s, ok = string_to_value_{{.Type}}[string(text)]; !ok { | ||
return ErrUnknown{{.Type}} | ||
} | ||
return nil | ||
} | ||
|
||
func (s {{.Type}}) MarshalText() ([]byte, error) { return vals_{{.Type}}[s], nil } | ||
func (s {{.Type}}) MarshalText() ([]byte, error) { return value_to_bytes_{{.Type}}[s], nil } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var seq_string_{{.Type}} = [...]string{{{.seq_string}}} | ||
|
||
func (s {{.Type}}) String() string { | ||
switch s { | ||
{{.value_to_string}} | ||
default: | ||
return "" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
func (s {{.Type}}) String() string { | ||
b, _ := s.MarshalText() | ||
return string(b) | ||
var value_to_string_{{.Type}} = map[{{.Type}}]string{ | ||
{{.value_to_string}} | ||
} | ||
|
||
func (s {{.Type}}) String() string { return value_to_string_{{.Type}}[s] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 12 additions & 11 deletions
23
...l/testdata/exp/size_enum_encoding_test.go → ...nal/testdata/color2_enum_encoding_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.