Skip to content

Commit

Permalink
Merge pull request #112 from sixstone-qq/sixstone-002/add-suffix-tag
Browse files Browse the repository at this point in the history
Add support to suffix in generated files
  • Loading branch information
sixstone-qq authored Sep 29, 2022
2 parents 2f12594 + c975c5f commit 38f7b5f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/avrogo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
// -p string
// package name (defaults to $GOPACKAGE)
// -t generated files will have _test.go suffix
// -map string
// map from Avro namespace to Go package.
// -s string
// suffix for generated files (default "_gen")
//
// By default, a type is generated for each Avro definition
// in the schema. Some additional metadata fields are
Expand Down Expand Up @@ -49,6 +49,7 @@ var (
dirFlag = flag.String("d", ".", "directory to write Go files to")
pkgFlag = flag.String("p", os.Getenv("GOPACKAGE"), "package name (defaults to $GOPACKAGE)")
testFlag = flag.Bool("t", strings.HasSuffix(os.Getenv("GOFILE"), "_test.go"), "generated files will have _test.go suffix (defaults to true if $GOFILE is a test file)")
suffixFlag = flag.String("s", "_gen", "suffix for generated files")
)

var flag = stdflag.NewFlagSet("", stdflag.ContinueOnError)
Expand Down Expand Up @@ -148,7 +149,7 @@ func outputPath(filename string, testFile bool) string {
filename = filepath.Clean(filename)
filename = filename[len(filepath.VolumeName(filename)):]
filename = filepath.ToSlash(filename)
filename = strings.TrimSuffix(filename, filepath.Ext(filename)) + "_gen"
filename = strings.TrimSuffix(filename, filepath.Ext(filename)) + *suffixFlag
if testFile {
filename += "_test"
}
Expand Down

0 comments on commit 38f7b5f

Please sign in to comment.