Open wjiec opened 1 month ago
Obviously, you declared a structure, but the yaml file contains a string. The types do not match.
@kesonan Thanks for the quick reply, as you can see, in order to convert the string type to the struct type I need, I implemented a unmarshaler to enable custom unmarshal of the string. But from the code it looks like go-zero first deserializes the YAML data into a map[string]any
object and then tries to assign from the map
object to the corresponding Config
structure, which obviously loses support for yaml.Unmarshaler
.
Describe the bug Unable to load configs with custom types and as well as custom
UnmarshalYAML
implementations.To Reproduce
type DurationOrCronSpec struct { dur time.Duration spec string }
func (d DurationOrCronSpec) UnmarshalYAML(value yaml.Node) error { if value.Kind != yaml.ScalarNode { return fmt.Errorf("pipeline must contain YAML scalar, has %v", value.Kind) }
}
The error is
Expected behavior Load configuration files correctly
Environments (please complete the following information):
More description I think that's enough.