Documentation
¶
Overview ¶
Package sqlcdebug parses the SQLCDEBUG environment variable and exposes its key=value settings to the rest of the codebase.
The SQLCDEBUG variable is a comma-separated list of name=value pairs:
SQLCDEBUG=dumpast=1,trace=trace.out
Settings are looked up at the call site by declaring a package-level variable:
var dumpAST = sqlcdebug.New("dumpast")
func parse() {
if dumpAST.Value() == "1" { ... }
}
New panics if name is not registered in Settings below. Adding a new setting therefore requires extending the Settings table so that all known keys are documented in one place.
This package is modeled after Go's internal/godebug. Unlike Go, sqlc is short-lived, so settings are parsed once at process startup; the Update hook exists for tests that need to reparse mid-run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Settings = []Info{
{Name: "dumpast", Description: "print the AST of every SQL statement"},
{Name: "dumpcatalog", Description: "print the parsed database schema"},
{Name: "trace", Description: "write a runtime trace to the named file (1 means trace.out)"},
{Name: "processplugins", Description: "set to 0 to disable process-based plugins", Default: "1"},
{Name: "databases", Description: "set to 'managed' to disable database connections via URI"},
{Name: "dumpvetenv", Description: "print the variables available to a vet rule during evaluation"},
{Name: "dumpexplain", Description: "print the JSON-formatted output from EXPLAIN during vet evaluation"},
}
Settings is the master table of all known SQLCDEBUG keys. New keys must be added here before they can be looked up via New.
Functions ¶
Types ¶
type Info ¶
type Info struct {
// Name is the SQLCDEBUG key, e.g. "dumpast".
Name string
// Description is a short human-readable description.
Description string
// Default is the value returned by [Setting.Value] when the key is
// not present in SQLCDEBUG.
Default string
}
Info documents a single SQLCDEBUG setting.
type Setting ¶
type Setting struct {
// contains filtered or unexported fields
}
Setting is a single SQLCDEBUG key. Obtain one with New; reading it with Setting.Value returns the value parsed from the SQLCDEBUG environment variable, or the registered default.
func New ¶
New returns the Setting for name. The same pointer is returned for repeated calls. New panics if name is not present in Settings.