render

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manifest

type Manifest struct {
	JSON struct {
		ScanTypeMap string   `json:"scanTypeMap"`
		PerRun      []string `json:"perRun"`
		PerTable    []string `json:"perTable"`
		PerStmtXML  []string `json:"perStmtXML"`
	}

	ScanTypeMap ScanTypeMap
	PerRun      [][2]*template.Template // [nameTmpl, contentTmpl]
	PerTable    [][2]*template.Template
	PerStmtXML  [][2]*template.Template
	// contains filtered or unexported fields
}

Manifest contains file and template information.

func LoadManifest

func LoadManifest(dir http.FileSystem, funcMap template.FuncMap) (*Manifest, error)

LoadManifest loads file and templates from a manifest in a directory.

type Option

type Option func(*Renderer) error

Option is used to create Renderer.

func Blacklist

func Blacklist(blacklist []string) Option

Blacklist sets the blacklist of table names to render.

func DSN

func DSN(dsn string) Option

DSN sets the data source name. (required)

func OutputDir

func OutputDir(outputDir string) Option

OutputDir sets the output directory. It will mkdir if not exists. (required)

func OutputPkg

func OutputPkg(outputPkg string) Option

OutputPkg sets an alternative package name for the generated code. By default the output directory is used.

func StmtDir

func StmtDir(stmtDir string) Option

StmtDir sets the statement xml directory.

func TmplDir

func TmplDir(tmplDir http.FileSystem) Option

TmplDir sets the template directory. (required)

func Whitelist

func Whitelist(whitelist []string) Option

Whitelist sets the whitelist of table names to render.

type Renderer

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

Renderer is used to render templates to final source code.

func NewRenderer

func NewRenderer(opts ...Option) (*Renderer, error)

NewRenderer creates a new Renderer.

func (*Renderer) Run

func (r *Renderer) Run() error

Run the render process.

type ScanTypeMap

type ScanTypeMap map[string][2]string

ScanTypeMap maps data type to scan type. [0] is for not nullable types. [1] is for nullable types.

func LoadScanTypeMap

func LoadScanTypeMap(r io.Reader) (ScanTypeMap, error)

LoadScanTypeMap loads scan type map from io.Reader.

func (ScanTypeMap) NotNullScanType

func (m ScanTypeMap) NotNullScanType(col interface{}) (string, error)

NotNullScanType returns the not nullable scan type for the (table or query result) column.

func (ScanTypeMap) NullScanType

func (m ScanTypeMap) NullScanType(col interface{}) (string, error)

NullScanType returns the nullable scan type for the (table or query result) column.

func (ScanTypeMap) ScanType

func (m ScanTypeMap) ScanType(col interface{}) (string, error)

ScanType returns the scan type for the (table or query result) column.

Jump to

Keyboard shortcuts

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