github.com/hamba/avro/v2@v2.22.1-0.20240518180522-aff3955acf7d/gen/testdata/golden_encoders.go (about) 1 package something 2 3 // Code generated by avro/gen. DO NOT EDIT. 4 5 import ( 6 "math/big" 7 "time" 8 9 "github.com/hamba/avro/v2" 10 ) 11 12 // InnerRecord is a generated struct. 13 type InnerRecord struct { 14 InnerJustBytes []byte `avro:"innerJustBytes"` 15 InnerPrimitiveNullableArrayUnion *[]string `avro:"innerPrimitiveNullableArrayUnion"` 16 } 17 18 var schemaInnerRecord = avro.MustParse(`{"name":"a.c.InnerRecord","type":"record","fields":[{"name":"innerJustBytes","type":"bytes"},{"name":"innerPrimitiveNullableArrayUnion","type":["null",{"type":"array","items":"string"}]}]}`) 19 20 // Schema returns the schema for InnerRecord. 21 func (o *InnerRecord) Schema() avro.Schema { 22 return schemaInnerRecord 23 } 24 25 // Unmarshal decodes b into the receiver. 26 func (o *InnerRecord) Unmarshal(b []byte) error { 27 return avro.Unmarshal(o.Schema(), b, o) 28 } 29 30 // Marshal encodes the receiver. 31 func (o *InnerRecord) Marshal() ([]byte, error) { 32 return avro.Marshal(o.Schema(), o) 33 } 34 35 // RecordInMap is a generated struct. 36 type RecordInMap struct { 37 Name string `avro:"name"` 38 } 39 40 var schemaRecordInMap = avro.MustParse(`{"name":"a.b.RecordInMap","type":"record","fields":[{"name":"name","type":"string"}]}`) 41 42 // Schema returns the schema for RecordInMap. 43 func (o *RecordInMap) Schema() avro.Schema { 44 return schemaRecordInMap 45 } 46 47 // Unmarshal decodes b into the receiver. 48 func (o *RecordInMap) Unmarshal(b []byte) error { 49 return avro.Unmarshal(o.Schema(), b, o) 50 } 51 52 // Marshal encodes the receiver. 53 func (o *RecordInMap) Marshal() ([]byte, error) { 54 return avro.Marshal(o.Schema(), o) 55 } 56 57 // RecordInArray is a generated struct. 58 type RecordInArray struct { 59 AString string `avro:"aString"` 60 } 61 62 var schemaRecordInArray = avro.MustParse(`{"name":"a.b.recordInArray","type":"record","fields":[{"name":"aString","type":"string"}]}`) 63 64 // Schema returns the schema for RecordInArray. 65 func (o *RecordInArray) Schema() avro.Schema { 66 return schemaRecordInArray 67 } 68 69 // Unmarshal decodes b into the receiver. 70 func (o *RecordInArray) Unmarshal(b []byte) error { 71 return avro.Unmarshal(o.Schema(), b, o) 72 } 73 74 // Marshal encodes the receiver. 75 func (o *RecordInArray) Marshal() ([]byte, error) { 76 return avro.Marshal(o.Schema(), o) 77 } 78 79 // RecordInNullableUnion is a generated struct. 80 type RecordInNullableUnion struct { 81 AString string `avro:"aString"` 82 } 83 84 var schemaRecordInNullableUnion = avro.MustParse(`{"name":"a.b.recordInNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}`) 85 86 // Schema returns the schema for RecordInNullableUnion. 87 func (o *RecordInNullableUnion) Schema() avro.Schema { 88 return schemaRecordInNullableUnion 89 } 90 91 // Unmarshal decodes b into the receiver. 92 func (o *RecordInNullableUnion) Unmarshal(b []byte) error { 93 return avro.Unmarshal(o.Schema(), b, o) 94 } 95 96 // Marshal encodes the receiver. 97 func (o *RecordInNullableUnion) Marshal() ([]byte, error) { 98 return avro.Marshal(o.Schema(), o) 99 } 100 101 // Record1InNonNullableUnion is a generated struct. 102 type Record1InNonNullableUnion struct { 103 AString string `avro:"aString"` 104 } 105 106 var schemaRecord1InNonNullableUnion = avro.MustParse(`{"name":"a.b.record1InNonNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}`) 107 108 // Schema returns the schema for Record1InNonNullableUnion. 109 func (o *Record1InNonNullableUnion) Schema() avro.Schema { 110 return schemaRecord1InNonNullableUnion 111 } 112 113 // Unmarshal decodes b into the receiver. 114 func (o *Record1InNonNullableUnion) Unmarshal(b []byte) error { 115 return avro.Unmarshal(o.Schema(), b, o) 116 } 117 118 // Marshal encodes the receiver. 119 func (o *Record1InNonNullableUnion) Marshal() ([]byte, error) { 120 return avro.Marshal(o.Schema(), o) 121 } 122 123 // Record2InNonNullableUnion is a generated struct. 124 type Record2InNonNullableUnion struct { 125 AString string `avro:"aString"` 126 } 127 128 var schemaRecord2InNonNullableUnion = avro.MustParse(`{"name":"a.b.record2InNonNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}`) 129 130 // Schema returns the schema for Record2InNonNullableUnion. 131 func (o *Record2InNonNullableUnion) Schema() avro.Schema { 132 return schemaRecord2InNonNullableUnion 133 } 134 135 // Unmarshal decodes b into the receiver. 136 func (o *Record2InNonNullableUnion) Unmarshal(b []byte) error { 137 return avro.Unmarshal(o.Schema(), b, o) 138 } 139 140 // Marshal encodes the receiver. 141 func (o *Record2InNonNullableUnion) Marshal() ([]byte, error) { 142 return avro.Marshal(o.Schema(), o) 143 } 144 145 // Record1InNullableUnion is a generated struct. 146 type Record1InNullableUnion struct { 147 AString string `avro:"aString"` 148 } 149 150 var schemaRecord1InNullableUnion = avro.MustParse(`{"name":"a.b.record1InNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}`) 151 152 // Schema returns the schema for Record1InNullableUnion. 153 func (o *Record1InNullableUnion) Schema() avro.Schema { 154 return schemaRecord1InNullableUnion 155 } 156 157 // Unmarshal decodes b into the receiver. 158 func (o *Record1InNullableUnion) Unmarshal(b []byte) error { 159 return avro.Unmarshal(o.Schema(), b, o) 160 } 161 162 // Marshal encodes the receiver. 163 func (o *Record1InNullableUnion) Marshal() ([]byte, error) { 164 return avro.Marshal(o.Schema(), o) 165 } 166 167 // Record2InNullableUnion is a generated struct. 168 type Record2InNullableUnion struct { 169 AString string `avro:"aString"` 170 } 171 172 var schemaRecord2InNullableUnion = avro.MustParse(`{"name":"a.b.record2InNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}`) 173 174 // Schema returns the schema for Record2InNullableUnion. 175 func (o *Record2InNullableUnion) Schema() avro.Schema { 176 return schemaRecord2InNullableUnion 177 } 178 179 // Unmarshal decodes b into the receiver. 180 func (o *Record2InNullableUnion) Unmarshal(b []byte) error { 181 return avro.Unmarshal(o.Schema(), b, o) 182 } 183 184 // Marshal encodes the receiver. 185 func (o *Record2InNullableUnion) Marshal() ([]byte, error) { 186 return avro.Marshal(o.Schema(), o) 187 } 188 189 // Test is a generated struct. 190 type Test struct { 191 AString string `avro:"aString"` 192 ABoolean bool `avro:"aBoolean"` 193 AnInt int `avro:"anInt"` 194 AFloat float32 `avro:"aFloat"` 195 ADouble float64 `avro:"aDouble"` 196 ALong int64 `avro:"aLong"` 197 JustBytes []byte `avro:"justBytes"` 198 PrimitiveNullableArrayUnion *[]string `avro:"primitiveNullableArrayUnion"` 199 InnerRecord InnerRecord `avro:"innerRecord"` 200 AnEnum string `avro:"anEnum"` 201 AFixed [7]byte `avro:"aFixed"` 202 ALogicalFixed avro.LogicalDuration `avro:"aLogicalFixed"` 203 AnotherLogicalFixed avro.LogicalDuration `avro:"anotherLogicalFixed"` 204 MapOfStrings map[string]string `avro:"mapOfStrings"` 205 MapOfRecords map[string]RecordInMap `avro:"mapOfRecords"` 206 ADate time.Time `avro:"aDate"` 207 ADuration time.Duration `avro:"aDuration"` 208 ALongTimeMicros time.Duration `avro:"aLongTimeMicros"` 209 ALongTimestampMillis time.Time `avro:"aLongTimestampMillis"` 210 ALongTimestampMicro time.Time `avro:"aLongTimestampMicro"` 211 ABytesDecimal *big.Rat `avro:"aBytesDecimal"` 212 ARecordArray []RecordInArray `avro:"aRecordArray"` 213 NullableRecordUnion *RecordInNullableUnion `avro:"nullableRecordUnion"` 214 NonNullableRecordUnion any `avro:"nonNullableRecordUnion"` 215 NullableRecordUnionWith3Options any `avro:"nullableRecordUnionWith3Options"` 216 Ref Record2InNullableUnion `avro:"ref"` 217 UUID string `avro:"uuid"` 218 } 219 220 var schemaTest = avro.MustParse(`{"name":"a.b.test","type":"record","fields":[{"name":"aString","type":"string"},{"name":"aBoolean","type":"boolean"},{"name":"anInt","type":"int"},{"name":"aFloat","type":"float"},{"name":"aDouble","type":"double"},{"name":"aLong","type":"long"},{"name":"justBytes","type":"bytes"},{"name":"primitiveNullableArrayUnion","type":["null",{"type":"array","items":"string"}]},{"name":"innerRecord","type":{"name":"a.c.InnerRecord","type":"record","fields":[{"name":"innerJustBytes","type":"bytes"},{"name":"innerPrimitiveNullableArrayUnion","type":["null",{"type":"array","items":"string"}]}]}},{"name":"anEnum","type":{"name":"a.b.Cards","type":"enum","symbols":["SPADES","HEARTS","DIAMONDS","CLUBS"]}},{"name":"aFixed","type":{"name":"a.b.fixedField","type":"fixed","size":7}},{"name":"aLogicalFixed","type":{"name":"a.b.logicalDuration","type":"fixed","size":12,"logicalType":"duration"}},{"name":"anotherLogicalFixed","type":"a.b.logicalDuration"},{"name":"mapOfStrings","type":{"type":"map","values":"string"}},{"name":"mapOfRecords","type":{"type":"map","values":{"name":"a.b.RecordInMap","type":"record","fields":[{"name":"name","type":"string"}]}}},{"name":"aDate","type":{"type":"int","logicalType":"date"}},{"name":"aDuration","type":{"type":"int","logicalType":"time-millis"}},{"name":"aLongTimeMicros","type":{"type":"long","logicalType":"time-micros"}},{"name":"aLongTimestampMillis","type":{"type":"long","logicalType":"timestamp-millis"}},{"name":"aLongTimestampMicro","type":{"type":"long","logicalType":"timestamp-micros"}},{"name":"aBytesDecimal","type":{"type":"bytes","logicalType":"decimal","precision":4,"scale":2}},{"name":"aRecordArray","type":{"type":"array","items":{"name":"a.b.recordInArray","type":"record","fields":[{"name":"aString","type":"string"}]}}},{"name":"nullableRecordUnion","type":["null",{"name":"a.b.recordInNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}]},{"name":"nonNullableRecordUnion","type":[{"name":"a.b.record1InNonNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]},{"name":"a.b.record2InNonNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}]},{"name":"nullableRecordUnionWith3Options","type":["null",{"name":"a.b.record1InNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]},{"name":"a.b.record2InNullableUnion","type":"record","fields":[{"name":"aString","type":"string"}]}]},{"name":"ref","type":"a.b.record2InNullableUnion"},{"name":"uuid","type":{"type":"string","logicalType":"uuid"}}]}`) 221 222 // Schema returns the schema for Test. 223 func (o *Test) Schema() avro.Schema { 224 return schemaTest 225 } 226 227 // Unmarshal decodes b into the receiver. 228 func (o *Test) Unmarshal(b []byte) error { 229 return avro.Unmarshal(o.Schema(), b, o) 230 } 231 232 // Marshal encodes the receiver. 233 func (o *Test) Marshal() ([]byte, error) { 234 return avro.Marshal(o.Schema(), o) 235 }