Go-Template
Go-Template copied to clipboard
fix bug found in processing output path
The existing code of computing the final output path
outputFileName := strings.TrimSuffix(*dataFileName, filepath.Ext(*dataFileName)) + ".generated.txt"
does not take into account that the dataFileName can be a path rather than just a filename.
The outputFileName has not been completely stripped off the path prefix, before the code join it with the output path
absOutputFileName := path.Join(outputDirectory, outputFileName)
This will result in this strange behavior:
$ ./Go-Template -d ../examples/02-loop/db-schema.json -t ../examples/02-loop/db-schema.tpl -o ../examples/02-loop/
Generating file : ../examples/examples/02-loop/db-schema.generated.txt
This fix addresses this issue. With the fix, the same command will behavior like this:
./Go-Template -d ../examples/02-loop/db-schema.json -t ../examples/02-loop/db-schema.tpl -o ../examples/02-loop/
Generating file : ../examples/02-loop/db-schema.generated.txt