Developing sqlc
Building
For local development, installsqlc
under an alias. We suggestsqlc-dev
.
gobuild-o~/go/bin/sqlc-dev./cmd/sqlc
Installsqlc-gen-json
to avoid test failure.
gobuild-o~/go/bin/sqlc-gen-json./cmd/sqlc-gen-json
Running Tests
gotest./...
To run the tests in the examples folder, use theexamples
tag.
gotest--tags=examples./...
These tests require locally-running database instances. Run these databasesusingDocker Compose.
dockercomposeup-d
The tests use the following environment variables to connect to thedatabase
For PostgreSQL
VariableDefaultValue-------------------------PG_HOST127.0.0.1PG_PORT5432PG_USERpostgresPG_PASSWORDmysecretpasswordPG_DATABASEdinotest
For MySQL
VariableDefaultValue-------------------------MYSQL_HOST127.0.0.1MYSQL_PORT3306MYSQL_USERrootMYSQL_ROOT_PASSWORDmysecretpasswordMYSQL_DATABASEdinotest