From 01b716cfc0ce2e4e28cb42f1a05301d405d18130 Mon Sep 17 00:00:00 2001 From: Blorgbeard Date: Sun, 9 Jun 2024 19:18:14 -0700 Subject: [PATCH] Address comments --- cmd/avrogen/testdata/golden.go | 2 +- cmd/avrogen/testdata/golden_encoders.go | 2 +- cmd/avrogen/testdata/golden_fullname.go | 2 +- cmd/avrogen/testdata/golden_stricttypes.go | 2 +- gen/gen.go | 2 +- gen/output_template.tmpl | 6 ++++-- gen/testdata/golden.go | 10 +++++++++- gen/testdata/golden_encoders.go | 10 +++++++++- gen/testdata/golden_fullname.go | 10 +++++++++- gen/testdata/golden_multiple.go | 4 +++- 10 files changed, 39 insertions(+), 11 deletions(-) diff --git a/cmd/avrogen/testdata/golden.go b/cmd/avrogen/testdata/golden.go index e76aef65..ac853d82 100644 --- a/cmd/avrogen/testdata/golden.go +++ b/cmd/avrogen/testdata/golden.go @@ -1,7 +1,7 @@ // package testpkg is generated from schema.avsc package testpkg -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. // Test is a test struct type Test struct { diff --git a/cmd/avrogen/testdata/golden_encoders.go b/cmd/avrogen/testdata/golden_encoders.go index 1c5b2fdb..3223d40c 100644 --- a/cmd/avrogen/testdata/golden_encoders.go +++ b/cmd/avrogen/testdata/golden_encoders.go @@ -1,6 +1,6 @@ package testpkg -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. import ( "github.com/hamba/avro/v2" diff --git a/cmd/avrogen/testdata/golden_fullname.go b/cmd/avrogen/testdata/golden_fullname.go index bdec65cd..fde53af1 100644 --- a/cmd/avrogen/testdata/golden_fullname.go +++ b/cmd/avrogen/testdata/golden_fullname.go @@ -1,6 +1,6 @@ package testpkg -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. // Test is a test struct type ABTest struct { diff --git a/cmd/avrogen/testdata/golden_stricttypes.go b/cmd/avrogen/testdata/golden_stricttypes.go index 1e721b3e..0ddc2c8e 100644 --- a/cmd/avrogen/testdata/golden_stricttypes.go +++ b/cmd/avrogen/testdata/golden_stricttypes.go @@ -1,6 +1,6 @@ package testpkg -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. // Test is a test struct type Test struct { diff --git a/gen/gen.go b/gen/gen.go index 9a785522..38a798c6 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -147,7 +147,7 @@ func WithStrictTypes(b bool) OptsFunc { } } -// WithPackageDoc configures the generator to use output the given text as a package doc comment. +// WithPackageDoc configures the generator to output the given text as a package doc comment. func WithPackageDoc(text string) OptsFunc { return func(g *Generator) { g.pkgdoc = text diff --git a/gen/output_template.tmpl b/gen/output_template.tmpl index 17a54119..1143fe52 100644 --- a/gen/output_template.tmpl +++ b/gen/output_template.tmpl @@ -3,7 +3,7 @@ {{- end }} package {{ .PackageName }} -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. {{- $encoders := .WithEncoders }} {{ if len .Imports }} @@ -17,7 +17,9 @@ package {{ .PackageName }} {{- range .Typedefs }} {{- if len .Doc }} // {{ .Doc }} - {{- end}} + {{- else }} + // {{ .Name }} is a generated struct. + {{- end }} type {{ .Name }} struct { {{- range .Fields }} {{- $f := . }} diff --git a/gen/testdata/golden.go b/gen/testdata/golden.go index 724b5d3b..8eb5918f 100644 --- a/gen/testdata/golden.go +++ b/gen/testdata/golden.go @@ -1,6 +1,6 @@ package something -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. import ( "math/big" @@ -9,35 +9,43 @@ import ( "github.com/hamba/avro/v2" ) +// InnerRecord is a generated struct. type InnerRecord struct { InnerJustBytes []byte `avro:"innerJustBytes"` InnerPrimitiveNullableArrayUnion *[]string `avro:"innerPrimitiveNullableArrayUnion"` } +// RecordInMap is a generated struct. type RecordInMap struct { Name string `avro:"name"` } +// RecordInArray is a generated struct. type RecordInArray struct { AString string `avro:"aString"` } +// RecordInNullableUnion is a generated struct. type RecordInNullableUnion struct { AString string `avro:"aString"` } +// Record1InNonNullableUnion is a generated struct. type Record1InNonNullableUnion struct { AString string `avro:"aString"` } +// Record2InNonNullableUnion is a generated struct. type Record2InNonNullableUnion struct { AString string `avro:"aString"` } +// Record1InNullableUnion is a generated struct. type Record1InNullableUnion struct { AString string `avro:"aString"` } +// Record2InNullableUnion is a generated struct. type Record2InNullableUnion struct { AString string `avro:"aString"` } diff --git a/gen/testdata/golden_encoders.go b/gen/testdata/golden_encoders.go index 5c8a8306..190a293c 100644 --- a/gen/testdata/golden_encoders.go +++ b/gen/testdata/golden_encoders.go @@ -1,6 +1,6 @@ package something -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. import ( "math/big" @@ -9,6 +9,7 @@ import ( "github.com/hamba/avro/v2" ) +// InnerRecord is a generated struct. type InnerRecord struct { InnerJustBytes []byte `avro:"innerJustBytes"` InnerPrimitiveNullableArrayUnion *[]string `avro:"innerPrimitiveNullableArrayUnion"` @@ -31,6 +32,7 @@ func (o *InnerRecord) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// RecordInMap is a generated struct. type RecordInMap struct { Name string `avro:"name"` } @@ -52,6 +54,7 @@ func (o *RecordInMap) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// RecordInArray is a generated struct. type RecordInArray struct { AString string `avro:"aString"` } @@ -73,6 +76,7 @@ func (o *RecordInArray) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// RecordInNullableUnion is a generated struct. type RecordInNullableUnion struct { AString string `avro:"aString"` } @@ -94,6 +98,7 @@ func (o *RecordInNullableUnion) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// Record1InNonNullableUnion is a generated struct. type Record1InNonNullableUnion struct { AString string `avro:"aString"` } @@ -115,6 +120,7 @@ func (o *Record1InNonNullableUnion) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// Record2InNonNullableUnion is a generated struct. type Record2InNonNullableUnion struct { AString string `avro:"aString"` } @@ -136,6 +142,7 @@ func (o *Record2InNonNullableUnion) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// Record1InNullableUnion is a generated struct. type Record1InNullableUnion struct { AString string `avro:"aString"` } @@ -157,6 +164,7 @@ func (o *Record1InNullableUnion) Marshal() ([]byte, error) { return avro.Marshal(o.Schema(), o) } +// Record2InNullableUnion is a generated struct. type Record2InNullableUnion struct { AString string `avro:"aString"` } diff --git a/gen/testdata/golden_fullname.go b/gen/testdata/golden_fullname.go index ef207ae6..5ebcb5f5 100644 --- a/gen/testdata/golden_fullname.go +++ b/gen/testdata/golden_fullname.go @@ -1,6 +1,6 @@ package something -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. import ( "math/big" @@ -9,35 +9,43 @@ import ( "github.com/hamba/avro/v2" ) +// ACInnerRecord is a generated struct. type ACInnerRecord struct { InnerJustBytes []byte `avro:"innerJustBytes"` InnerPrimitiveNullableArrayUnion *[]string `avro:"innerPrimitiveNullableArrayUnion"` } +// ABRecordInMap is a generated struct. type ABRecordInMap struct { Name string `avro:"name"` } +// ABRecordInArray is a generated struct. type ABRecordInArray struct { AString string `avro:"aString"` } +// ABRecordInNullableUnion is a generated struct. type ABRecordInNullableUnion struct { AString string `avro:"aString"` } +// ABRecord1InNonNullableUnion is a generated struct. type ABRecord1InNonNullableUnion struct { AString string `avro:"aString"` } +// ABRecord2InNonNullableUnion is a generated struct. type ABRecord2InNonNullableUnion struct { AString string `avro:"aString"` } +// ABRecord1InNullableUnion is a generated struct. type ABRecord1InNullableUnion struct { AString string `avro:"aString"` } +// ABRecord2InNullableUnion is a generated struct. type ABRecord2InNullableUnion struct { AString string `avro:"aString"` } diff --git a/gen/testdata/golden_multiple.go b/gen/testdata/golden_multiple.go index dcbfd74c..34c3f082 100644 --- a/gen/testdata/golden_multiple.go +++ b/gen/testdata/golden_multiple.go @@ -1,12 +1,14 @@ package something -// Code generated by avro/gen. DO NOT EDIT MANUALLY. +// Code generated by avro/gen. DO NOT EDIT. +// TestUnionType is a generated struct. type TestUnionType struct { Field1 int64 `avro:"Field1"` Field2 int `avro:"Field2"` } +// TestMain is a generated struct. type TestMain struct { TestUnion *TestUnionType `avro:"TestUnion"` }