https://github.com/mpyw/sqlc-restruct
Post-processor for kyleconroy/sqlc
https://github.com/mpyw/sqlc-restruct
database go golang postprocessing postprocessor sqlc
Last synced: 10 months ago
JSON representation
Post-processor for kyleconroy/sqlc
- Host: GitHub
- URL: https://github.com/mpyw/sqlc-restruct
- Owner: mpyw
- License: mit
- Created: 2023-07-04T16:41:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-19T02:51:31.000Z (almost 2 years ago)
- Last Synced: 2025-04-01T23:37:08.269Z (10 months ago)
- Topics: database, go, golang, postprocessing, postprocessor, sqlc
- Language: Go
- Homepage:
- Size: 41 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sqlc-restruct
**EXPERIMENTAL!**
Post-processor for [kyleconroy/sqlc](https://github.com/kyleconroy/sqlc)

```ShellSession
user@host:~$ sqlc-restruct --help
NAME:
sqlc-restruct - Post-processor for kyleconroy/sqlc
USAGE:
sqlc-restruct [global options] command [command options] [arguments...]
COMMANDS:
separate-interface Separates models and the `Querier` interface from the `Queries` struct. This is typically done to adhere to the Dependency Inversion Principle (DIP), allowing for more flexible and testable code.
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
```
## Installation
```
go install github.com/mpyw/sqlc-restruct/cmd/sqlc-restruct@latest
```
## SubCommands
### [separate-interface](./cmd/sqlc-restruct/separate_interface.go)
```ShellSession
user@host:~$ sqlc-restruct separate-interface --help
NAME:
sqlc-restruct separate-interface - Separates models and the `Querier` interface from the `Queries` struct. This is typically done to adhere to the Dependency Inversion Principle (DIP), allowing for more flexible and testable code.
USAGE:
sqlc-restruct separate-interface [command options] [arguments...]
OPTIONS:
--iface-pkg-name value The package name where the separated Querier will be located.
--iface-pkg-url value The package URL where the separated Querier will be located. (e.g. "github.com///path/to/pkg")
--iface-dir value The directory path where the separated Querier will be located.
--models-pkg-name value The package name where the separated models will be located. (default: --models-pkg-name value)
--models-pkg-url value The package URL where the separated models will be located. (default: --models-pkg-url value)
--models-dir value The directory path where the separated models will be located. (default: --iface-dir value)
--impl-dir value The original directory where the sqlc-generated code is located. (default: ".")
--impl-sql-suffix value The suffix for sqlc-generated files from SQL files. (default: ".sql.go")
--models-file-name value The file name for the sqlc-generated models file. (default: "models.go")
--querier-file-name value The file name for the sqlc-generated Querier file. (default: "querier.go")
--help, -h show help
```
We recommend chaining the `//go:generate` directive for `sqlc-restruct` right after the one for `sqlc` in your code.
```go
//go:generate sqlc generate
//go:generate sqlc-restruct separate-interface --iface-dir=domain/repos --iface-pkg-name=repos --iface-pkg-url=github.com/example/domain/repos
```