types

package
v0.62.9 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: BSD-2-Clause Imports: 10 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Invalid    = Kind(types.Invalid)
	Bool       = Kind(types.Bool)
	Int        = Kind(types.Int)
	Int8       = Kind(types.Int8)
	Int16      = Kind(types.Int16)
	Int32      = Kind(types.Int32)
	Int64      = Kind(types.Int64)
	Uint       = Kind(types.Uint)
	Uint8      = Kind(types.Uint8)
	Uint16     = Kind(types.Uint16)
	Uint32     = Kind(types.Uint32)
	Uint64     = Kind(types.Uint64)
	Float32    = Kind(types.Float32)
	Float64    = Kind(types.Float64)
	Complex64  = Kind(types.Complex64)
	Complex128 = Kind(types.Complex128)
	String     = Kind(types.String)

	Interface = 101
	Map       = 102
	Slice     = 103
	Struct    = 104
)
View Source
const TagKey = "sql"

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind types.BasicKind

func (Kind) BitWidth added in v0.14.0

func (k Kind) BitWidth() int

BitWidth returns the bit width of a given Go type.

func (Kind) IsFloat

func (k Kind) IsFloat() bool

IsInteger is true for both Go float types.

func (Kind) IsInteger

func (k Kind) IsInteger() bool

IsInteger is true for all Go integer types.

func (Kind) IsSimpleType

func (k Kind) IsSimpleType() bool

IsInteger is true for all Go primitive types, only.

func (Kind) IsUnsigned added in v0.14.0

func (k Kind) IsUnsigned() bool

IsUnsigned returns true only for Go's unsigned integer types.

func (Kind) String added in v0.17.0

func (k Kind) String() string

String returns a type as its string token. For the simple kinds, these are the standard Go language types.

type Tag

type Tag struct {
	Name       string `json:",omitempty" yaml:"name,omitempty"`     // explicit column name
	Type       string `json:",omitempty" yaml:"type,omitempty"`     // explicit column type (SQL syntax)
	Default    string `json:",omitempty" yaml:"default,omitempty"`  // default SQL value
	Prefixed   bool   `json:",omitempty" yaml:"prefixed,omitempty"` // use struct nesting to name the column
	Primary    bool   `json:",omitempty" yaml:"pk,omitempty"`       // is a primary key
	Natural    bool   `json:",omitempty" yaml:"nk,omitempty"`       // is a natural key so a unique index will be added automatically
	Auto       bool   `json:",omitempty" yaml:"auto,omitempty"`     // is auto-incremented
	Index      string `json:",omitempty" yaml:"index,omitempty"`    // the name of an index
	Unique     string `json:",omitempty" yaml:"unique,omitempty"`   // the name of a unique index
	ForeignKey string `json:",omitempty" yaml:"fk,omitempty"`       // relationship to another table
	OnUpdate   string `json:",omitempty" yaml:"onupdate,omitempty"` // what to do on update (no action, cascade, delete, restrict, set null, set default)
	OnDelete   string `json:",omitempty" yaml:"ondelete,omitempty"` // what to do on delete
	Size       int    `json:",omitempty" yaml:"size,omitempty"`     // storage size
	Encode     string `json:",omitempty" yaml:"encode,omitempty"`   // used for struct types: one of json | text | driver
	Skip       bool   `json:",omitempty" yaml:"skip,omitempty"`     // ignore the field

}

Tag stores the parsed data from the tag string in a struct field. These are all optional.

func ParseTag

func ParseTag(raw string) (*Tag, error)

ParseTag parses a tag string from the struct field and unmarshals into a Tag struct.

func (*Tag) ParentReference added in v0.13.0

func (tag *Tag) ParentReference() (string, string)

type Tags

type Tags map[string]*Tag

func ReadTagsFile

func ReadTagsFile(file string) (Tags, error)

func (Tags) String

func (tags Tags) String() string

Jump to

Keyboard shortcuts

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