jet icon indicating copy to clipboard operation
jet copied to clipboard

feature: export functions and remove internal package

Open switchupcb opened this issue 8 months ago • 5 comments
trafficstars

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:

  1. Use of internal: Using jet programmatically with an interpreter requires you to use functions which reference internal, when functions in an internal package cannot be referenced. So, the developer must rename the entire internal package to use jet with an interpreter.
  2. Unexported functions
    1. genTemplate is unexported which requires the developer to inline a definition or export the function to use jet programmatically.
    2. postgres package contains unexported functions which requires the developer to export them when using jet with 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

switchupcb avatar Mar 11 '25 16:03 switchupcb