We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to parse an enum from string:
readonly: deny
with readonly defined as:
readonly
type ReadOnlyMode int const ( ReadOnlyFalse ReadOnlyMode = iota ReadOnlyDeny ReadOnlyTrue )
Both Text- and Yaml unmarshaler are implemented:
var _ encoding.TextUnmarshaler = (*ReadOnlyMode)(nil) func (m *ReadOnlyMode) UnmarshalText(text []byte) error { mode, err := ReadOnlyModeString(string(text)) if err == nil { *m = mode } return err } var _ yaml.Unmarshaler = (*ReadOnlyMode)(nil) func (m *ReadOnlyMode) UnmarshalYAML(value *yaml.Node) error { mode, err := ReadOnlyModeString(value.Value) if err == nil { *m = mode } return err }
Yet decoding fails:
cannot parse 'ReadOnly' as int: strconv.ParseInt: parsing "deny": invalid syntax
It seems this may be a question of order: should it be possible for the presence of an unmarshaler to override the type detection (int)?
The text was updated successfully, but these errors were encountered:
Works fine for me: https://go.dev/play/p/NvGx1tx8vxN
Sorry, something went wrong.
No branches or pull requests
I'm trying to parse an enum from string:
with
readonly
defined as:Both Text- and Yaml unmarshaler are implemented:
Yet decoding fails:
It seems this may be a question of order: should it be possible for the presence of an unmarshaler to override the type detection (int)?
The text was updated successfully, but these errors were encountered: