Skip to content

Add a code generator #3

Description

@dolmen

Add a code generation tool sqlfunc-gen that processes source code containing calls to ForEach/Scan/Exec/QueryRow/Query, and provides:

  • linter functionality: due to limitation in Go's type system and Go generics, sqlfunc relies heavily on runtime analysis of the functions signatures using reflect. By leveraging static analysis the tool would give early feedback about mismatches between user's code and sqlfunc expectations.
  • code generation: the sqlfunc registry has been designed to cache bindings produced by sqlfunc to reduce the costs of runtime type checking mentionned above. But it is also designed to be pre-populated with functions compiled in the program and attached in source code of each package that uses sqlfunc. The tool would generate the function code and the registration code without any user involvement beyond adding a call to sqlfunc-gen via a //go:generate line in each package that uses sqlfunc.

The generated files will have a "sqlfunc_gen" prefix and a suffix based on the test context.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions