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
package main import ( "encoding" "errors" "fmt" "log/slog" "gopkg.in/yaml.v3" ) type obj struct { Values []value `yaml:"values"` } type value struct { param int } var _ encoding.TextUnmarshaler = (*value)(nil) func (v *value) UnmarshalText(b []byte) (err error) { slog.Info("unmarshal", "b", b) return errors.New("unmarshal error") } const data = ` values: - a:: ` func main() { o := &obj{} err := yaml.Unmarshal([]byte(data), o) slog.Info("result", "err", err, "o", fmt.Sprintf("%#v", o)) }
The slog.Info in (*value).UnmarshalText to be called; an error.
slog.Info
(*value).UnmarshalText
2009/11/10 23:00:00 INFO result err=<nil> o=&main.obj{Values:[]main.value{main.value{param:0}}}
https://go.dev/play/p/1ucYRvnupUE
The text was updated successfully, but these errors were encountered:
https://go.dev/play/p/pdgVwWvlIZk
Looks like - a:: isn't interpreted as a string, instead it's treated as a map value.
- a::
string
Sorry, something went wrong.
No branches or pull requests
Code
Expected
The
slog.Info
in(*value).UnmarshalText
to be called; an error.Actual
https://go.dev/play/p/1ucYRvnupUE
The text was updated successfully, but these errors were encountered: