sqlc-tidy is a tool that removes unused queries from the code generated by SQLC. It reads the sqlc configuration file, checks if the auto-generated queries are used in the code, and removes unused queries from the auto-generated files. Note that it does not delete auto-generated mocks, so after running sqlc-tidy, you need to run sqlc again to regenerate the auto-generated files.
$ go install github.com/harakeishi/sqlc-tidy@latestRun it in the directory where the sqlc configuration file is located.
$ sqlc-tidyBelow is the result of running sqlc-tidy in the testdata directory of this repository.
$ sqlc-tidy
==delete==
file: query.sql
query: ListAuthors
==delete==
file: query.sql
query: CreateAuthor
==delete==
file: query.sql
query: DeleteAuthor