avro
avro copied to clipboard
struct defaults don't work correctly with all field types
The code to derive a default value from a Go struct is too naive. It doesn't cope when the JSON-formatted value isn't correct for Avro.
Here's a test case that fails:
tests: goTypeStructFieldWithEnum: {
inSchema: {
name: "R"
type: "record"
fields: []
}
goType: "R"
goTypeBody: """
struct {
S S
}
type S struct {
E Enum
}
type Enum int
func (e Enum) String() string {
return []string{"a", "b"}[e]
}
"""
inData: {}
outData: {
S: E: "a"
}
}