avro icon indicating copy to clipboard operation
avro copied to clipboard

Support original name for structs

Open ebooneBB opened this issue 2 years ago • 0 comments

A CLI option to allow for the original name in the avro schema (or fullname) to be maintained and capitalized in the resulting go struct would be beneficial.

Schema

{
  "name": "one_two_three_four__five",
  "type": "record",
  "fields": [
    {
      "name": "CreatedDate",
      "type": "long",
      "doc": "CreatedDate:DateTime"
    }
  ]
}

Current

Command

avrogen -pkg salesforce -o x.go -tags json:snake x.avsc

Output

package salesforce

// Code generated by avro/gen. DO NOT EDIT.

// OneTwoThreeFourFive is a generated struct.
type OneTwoThreeFourFive struct {
	CreatedDate int64 `avro:"CreatedDate" json:"created_date"`
}

Desired

Command (placeholder)

avrogen -pkg salesforce -o x.go -tags json:snake -originalname x.avsc

Output

package salesforce

// Code generated by avro/gen. DO NOT EDIT.

// One_two_three_four__five is a generated struct.
type One_two_three_four__five struct {
	CreatedDate int64 `avro:"CreatedDate" json:"created_date"`
}

ebooneBB avatar Oct 05 '23 19:10 ebooneBB