Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug found in processing output path #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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