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.
Add a code generation tool
sqlfunc-genthat processes source code containing calls toForEach/Scan/Exec/QueryRow/Query, and provides:sqlfuncrelies heavily on runtime analysis of the functions signatures usingreflect. By leveraging static analysis the tool would give early feedback about mismatches between user's code and sqlfunc expectations.sqlfunc. The tool would generate the function code and the registration code without any user involvement beyond adding a call tosqlfunc-genvia a//go:generateline in each package that usessqlfunc.The generated files will have a
"sqlfunc_gen"prefix and a suffix based on the test context.