kevinconway / wrapgen

Interface wrapper generator for Go
Apache License 2.0
26 stars 9 forks source link

Fix source package name detection #13

Closed kevinconway closed 3 years ago

kevinconway commented 3 years ago

The previous version assumed that the package path ended with the package name. In cases where the package path contained invalid package characters, like "-", the tools would generate invalid output.

The naive solution to this would be to use the --package flag to set the name to something valid. However, this flag indicates that the source and destination packages are different. This results in the source package receiving an import alias to prevent conflicts. This means that any package generated using --package that is rendered within the file tree of --source also results in an invalid file.

This patch preserves all existing behaviors except that it now correctly extracts the true package name rather than relying on the package path.

kevinconway commented 3 years ago

/cc @orian since this interacts a bit with the patch you added. This latest change still works as expected with your patch. I added a few more tests for the cases you added after I caused a regression. Thanks again for your PR. It came through just as I was needing to pull this tool into a new project.