jet
jet copied to clipboard
feature: export functions and remove internal package
How can you increase the library's usage and contributions?
Problem
You are limiting the library's usage and contributions by using an internal package and unexported functions.
dbgo uses a modified version of jet to interpret a Go file and output type-safe SQL.
Here are the issues experienced while implementing this functionality:
- Use of
internal: Usingjetprogrammatically with an interpreter requires you to use functions which referenceinternal, when functions in aninternalpackage cannot be referenced. So, the developer must rename the entireinternalpackage to usejetwith an interpreter. - Unexported functions
genTemplateis unexported which requires the developer to inline a definition or export the function to usejetprogrammatically.postgrespackage contains unexported functions which requires the developer to export them when usingjetwith an interpreter.
Implementation
You can increase the library's usage and contributions by replacing the internal package and exporting certain unexported functions.
https://github.com/switchupcb/jet/tree/dbgo is a version of jet which has these problems fixed for PostgreSQL functionality.
Implementation: Internal Usage
The solution to this problem requires further discussion among maintainers.
Implementation: Export Unexported Functions
You can approve the decision to export unexported fuinctions required for usage of jet in an interpreter (e.g., functions in import "github.com/go-jet/jet/v2/postgres") and I can create a pull request to solve this problem.
Here are example commits:
- https://github.com/switchupcb/jet/commit/1ba2f4d55dacc2eb5513f0d40485531ee03e23c4
- https://github.com/switchupcb/jet/commit/26ee4c529d640ec60255d10c61387277b8749684