Skip to content

Conversation

@ewh0
Copy link
Contributor

@ewh0 ewh0 commented Jul 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant