token

package
Version: v0.0.0-...-81ee819 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StandardFormat         = NewFormat("", "", `"`, "")
	StandardIndentedFormat = NewFormat("", "  ", `"`, "")
	MySQLFormat            = NewFormat("", "", "`", "")
	MySQLIndentedFormat    = NewFormat("", "  ", "`", "")
)

Built-in formats.

View Source
var (
	LQuote = new(lquote)
	RQuote = new(rquote)
	SOL    = new(sol)
	EOL    = new(eol)
	Indent = new(indent)
)

Tokens that change behavior by setting Format.

View Source
var (
	Space       = NewWord(" ")
	Wildcard    = NewWord("*")
	Placeholder = NewWord("?")
	Period      = NewWord(".")
	Comma       = NewWord(",")
	LParen      = NewWord("(")
	RParen      = NewWord(")")
	FuncLParen  = NewWord("(")
	FuncRParen  = NewWord(")")
)

Tokens that don't change behavior according to Format setting.

Functions

func Generate

func Generate(tokens Tokens, format Format) string

Generate converts the tokens to text according to format.

Types

type Format

type Format struct {
	Prefix, Indent string
	IsBreaking     bool
	Quote, LineEnd string
}

Format is a setting for query building.

func NewFormat

func NewFormat(prefix, indent, quote, lineEnd string) Format

NewFormat returns a new Format for building queries.

type Token

type Token interface {
	Sprint(Format) string
	String() string
}

type Tokens

type Tokens []Token

func Flatten

func Flatten(tss ...Tokens) Tokens

func NewTokens

func NewTokens(tokens ...Token) Tokens

func Placeholders

func Placeholders(i int) Tokens

func Repeat

func Repeat(t Token, n int) Tokens

func (Tokens) Append

func (ts Tokens) Append(tokens ...Token) Tokens

func (Tokens) Sprint

func (ts Tokens) Sprint(format Format) string

type Word

type Word string

func NewWord

func NewWord(char string) *Word

func (Word) Sprint

func (w Word) Sprint(format Format) string

func (Word) String

func (w Word) String() string

Jump to

Keyboard shortcuts

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