https://github.com/optiopay/sqlgen
A sql.Scanner and sql.Valuer generator for Go
https://github.com/optiopay/sqlgen
library open-source sql
Last synced: 5 months ago
JSON representation
A sql.Scanner and sql.Valuer generator for Go
- Host: GitHub
- URL: https://github.com/optiopay/sqlgen
- Owner: optiopay
- License: mit
- Created: 2016-10-19T06:13:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-24T21:58:16.000Z (over 9 years ago)
- Last Synced: 2025-12-17T14:51:04.907Z (6 months ago)
- Topics: library, open-source, sql
- Language: Go
- Size: 59.6 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# sqlgen
This tool generates `sql.Scanner` and `sql.Valuer` interfaces for your own structs and type aliases. It is tested with Postgres and `lib/pq` library, others might work. The command is quite self explanatory, use the `--help` option to understand the parameters.
## Trying it out
The `example` folder provides you with tests and structs to understand how this tool works. Run `go generate` in the example folder to generate the interfaces. Then you can run `go test` to see if all works. It tries to connect to a local postgres instance and needs a database named `custom`.
The `-array` param generates array types as well, the `-sql` param adds a Init function that can be used to create the composite type in postgres.
## Aliases
There is support for type aliases. To generate scanner and valuer for type aliases you can pass them through the `alias` param.