avro icon indicating copy to clipboard operation
avro copied to clipboard

struct defaults don't work correctly with all field types

Open rogpeppe opened this issue 5 years ago • 0 comments

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"
	}
}

rogpeppe avatar Jan 24 '20 12:01 rogpeppe