codegen

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package codegen orchestrates the generation of Go code from SQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportedIdentifier

func ExportedIdentifier(raw string) string

ExportedIdentifier converts raw input into a public Go identifier.

func FileName

func FileName(raw string) string

FileName converts the raw name into a snake_case file name segment.

func UnexportedIdentifier

func UnexportedIdentifier(raw string) string

UnexportedIdentifier converts raw input into a private Go identifier.

func UniqueName

func UniqueName(base string, used map[string]int) (string, error)

UniqueName ensures returned identifier does not collide with previous values.

Types

type File

type File struct {
	Path    string
	Content []byte
}

File represents a generated source file.

type Generator

type Generator interface {
	Generate(ctx context.Context, catalog *model.Catalog, analyses []analyzer.Result) ([]File, error)
}

Generator produces Go code from parsed schemas and queries.

func New

func New(opts Options) Generator

New creates a new Generator.

type GeneratorFactory

type GeneratorFactory struct {
	// contains filtered or unexported fields
}

GeneratorFactory creates language-specific generators.

func NewGeneratorFactory

func NewGeneratorFactory(opts Options) *GeneratorFactory

NewGeneratorFactory creates a new generator factory.

func (*GeneratorFactory) Create

func (f *GeneratorFactory) Create(lang config.Language) (Generator, error)

Create returns a generator for the specified language.

type Options

type Options struct {
	Package             string
	Database            config.Database
	EmitJSONTags        bool
	EmitEmptySlices     bool
	EmitPointersForNull bool
	Prepared            PreparedOptions
	CustomTypes         []config.CustomTypeMapping
	SQL                 SQLOptions
}

Options configures the Generator.

type PreparedOptions

type PreparedOptions struct {
	Enabled     bool
	EmitMetrics bool
	ThreadSafe  bool
}

PreparedOptions configures prepared statement generation.

type SQLOptions

type SQLOptions struct {
	Enabled         bool
	Dialect         string
	EmitIFNotExists bool
}

SQLOptions configures SQL schema output.

Directories

Path Synopsis
Package ast provides types and logic for building Go ASTs.
Package ast provides types and logic for building Go ASTs.
Package render formats and writes generated Go code.
Package render formats and writes generated Go code.
Package rust generates Rust code using text templates.
Package rust generates Rust code using text templates.
Package sql generates SQL schema definitions from a database catalog.
Package sql generates SQL schema definitions from a database catalog.
Package typescript generates TypeScript code using text templates.
Package typescript generates TypeScript code using text templates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL