fix(go): add Postgres struct constructor #3440
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist (if applicable):
Disclaimer New to the library and might be missing how to add plugins, but I see the following issue:
Description
Currently, the Postgres struct doesn't export the engine data member, and at the same time, it has no way of adding it through a constructor or a setter.
In detail, in the file go/plugins/postgresql/genkit.go
And in the README.md, it says (go/plugins/postgresql/README.md)
which is not possible unless you are in the same package, since the engine is not exported. Thus, this blocks the use of any instance of a Postgres struct as a plugin directly with Genkit. For example, the following won't work just because the engine is not exportable
If one tries not to add an engine and just pass the Postgres struct instance as a plugin to GenKit, as in:
will fail with
panic: genkit.Init: plugin *postgresql.Postgres initialization failed: postgres.Init engine is nil
error, coming from the initialization of the plugin hereSolution
Add a constructor to the Postgres struct so it can be instantiated with an engine and thus passed to a genkit plugin