Documentation
¶
Overview ¶
Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types. The typical use is to take a value with static type interface{} and extract its dynamic type information by calling TypeOf, which returns a Type.
A call to ValueOf returns a Value representing the run-time data. Zero takes a Type and returns a Value representing a zero value for that type.
See "The Laws of Reflection" for an introduction to reflection in Go: https://golang.org/doc/articles/laws_of_reflection.html
Index ¶
- Constants
- func CreateTable(db *sql.DB, model interface{}) error
- func Delete(db *sql.DB, model interface{}) (int64, error)
- func Insert(db *sql.DB, model interface{}) (int64, error)
- func QueryRow(db *sql.DB, model interface{}) error
- func Scan(scanner Scanner, model interface{}) error
- func Update(db *sql.DB, model interface{}, fields ...Fields) (int64, error)
- type Column
- type ColumnConstraint
- type EntityContext
- type Fields
- type ForeignKey
- type Index
- type Metadata
- type RowScanner
- type Scanner
- type Schema
- type Tag
Constants ¶
const ( FieldCreatedAt = "created_at" FieldUpdatedAt = "updated_at" )
const ( TagColumnName = "sql" TagIndexName = "sqlindex" TagForeignKeyName = "sqlforeignkey" TagFieldNameIndex = 0 TagFieldDataTypeIndex = 1 )
const Separator = ",\n"
Variables ¶
This section is empty.
Functions ¶
func CreateTable ¶
Types ¶
type Column ¶
type Column struct { Name string Index int DataType string PrimaryKey bool Constraint ColumnConstraint }
type ColumnConstraint ¶
type ColumnConstraint byte
const ( ColumnConstraintUnique ColumnConstraint = 1 << iota ColumnConstraintNull ColumnConstraintNotNull )
func (ColumnConstraint) String ¶
func (c ColumnConstraint) String() string
type EntityContext ¶
type EntityContext struct {
// contains filtered or unexported fields
}
func NewEntityContext ¶
func NewEntityContext(model interface{}) *EntityContext
func (*EntityContext) Scan ¶
func (t *EntityContext) Scan(scanner Scanner) error
type ForeignKey ¶
type RowScanner ¶
func (*RowScanner) Columns ¶
func (s *RowScanner) Columns() ([]string, error)
func (*RowScanner) Scan ¶
func (s *RowScanner) Scan(dest ...interface{}) error
type Schema ¶
type Schema struct { Table string ForeignKeys []*ForeignKey Columns []*Column Indexes []*Index }
type Tag ¶
A StructTag is the tag string in a struct field.
By convention, tag strings are a concatenation of optionally space-separated key:"value" pairs. Each key is a non-empty string consisting of non-control characters other than space (U+0020 ' '), quote (U+0022 '"'), and colon (U+003A ':'). Each value is quoted using U+0022 '"' characters and Go string literal syntax.
func (Tag) Get ¶
Get returns the value associated with key in the tag string. If there is no such key in the tag, Get returns the empty string. If the tag does not have the conventional format, the value returned by Get is unspecified. To determine whether a tag is explicitly set to the empty string, use Lookup.
func (Tag) Lookup ¶
Lookup returns the value associated with key in the tag string. If the key is present in the tag the value (which may be empty) is returned. Otherwise the returned value will be the empty string. The ok return value reports whether the value was explicitly set in the tag string. If the tag does not have the conventional format, the value returned by Lookup is unspecified.