Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(opts GenerateOptions) (mErr error)
Generate generates language specific code to safely wrap each SQL ast.SourceQuery in opts.QueryFiles.
Generate must only be called once per output directory.
Types ¶
type GenerateOptions ¶
type GenerateOptions struct {
// What language to generate code in.
Language Lang
// The connection string to the running Postgres database to use to get type
// information for each query in QueryFiles.
//
// Must be parseable by pgconn.ParseConfig, like:
//
// # Example DSN
// user=jack password=secret host=pg.example.com port=5432 dbname=foo_db sslmode=verify-ca
//
// # Example URL
// postgres://jack:secret@pg.example.com:5432/foo_db?sslmode=verify-ca
ConnString string
// Generate code for each of the SQL query file paths.
QueryFiles []string
// Schema files to run on Postgres init. Can be *.sql, *.sql.gz, or executable
// *.sh files .
SchemaFiles []string
// The name of the Go package for the file. If empty, defaults to the
// directory name.
GoPackage string
// Directory to write generated files. Writes one file for each query file.
// If more than one query file, also writes querier.go.
OutputDir string
// A map of lowercase acronyms to the upper case equivalent, like:
// "api" => "API", or "apis" => "APIs".
Acronyms map[string]string
// A map from a Postgres type name to a fully qualified Go type.
TypeOverrides map[string]string
// What log level to log at.
LogLevel slog.Level
// How many params to inline when calling querier methods.
// Set to 0 to always create a struct for params.
InlineParamCount int
}
GenerateOptions are the unparsed options that controls the generated Go code.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pggen
command
|
|
|
example
|
|
|
internal
|
|
|
codegen
Package codegen contains common code shared between codegen and language specific code generators.
|
Package codegen contains common code shared between codegen and language specific code generators. |
|
gomod
Package gomod provides utilities for getting information about the current Go module.
|
Package gomod provides utilities for getting information about the current Go module. |
|
parser
Package parser contains the exported entry points for invoking the parser.
|
Package parser contains the exported entry points for invoking the parser. |
|
pgdocker
Package pgdocker creates one-off Postgres docker images to use so pggen can introspect the schema.
|
Package pgdocker creates one-off Postgres docker images to use so pggen can introspect the schema. |
Click to show internal directories.
Click to hide internal directories.