reform.v1: gopkg.in/reform.v1/parse Index | Files

package parse

import "gopkg.in/reform.v1/parse"

Package parse implements parsing of Go structs in files and runtime.

This package, despite containing exported types, methods and functions, is an internal part of implementation of 'reform' command, also used by generated files, and not a part of public stable API.

Index

Package Files

base.go file.go runtime.go

func AssertUpToDate Uses

func AssertUpToDate(si *StructInfo, obj interface{})

AssertUpToDate checks that given StructInfo matches given object. It is used during program initialization to check that generated files are up-to-date.

type FieldInfo Uses

type FieldInfo struct {
    Name   string // field name as defined in source file, e.g. Name
    Type   string // field type as defined in source file, e.g. string; always present for primary key, may be absent otherwise
    Column string // SQL database column name from "reform:" struct field tag, e.g. name
}

FieldInfo represents information about struct field.

type StructInfo Uses

type StructInfo struct {
    Type         string      // struct type as defined in source file, e.g. User
    SQLSchema    string      // SQL database schema name from magic "reform:" comment, e.g. public
    SQLName      string      // SQL database view or table name from magic "reform:" comment, e.g. users
    Fields       []FieldInfo // fields info
    PKFieldIndex int         // index of primary key field in Fields, -1 if none
}

StructInfo represents information about struct.

func File Uses

func File(path string) ([]StructInfo, error)

File parses given file and returns found structs information.

func Object Uses

func Object(obj interface{}, schema, table string) (res *StructInfo, err error)

Object extracts struct information from given object.

func (*StructInfo) Columns Uses

func (s *StructInfo) Columns() []string

Columns returns a new slice of column names.

func (*StructInfo) IsTable Uses

func (s *StructInfo) IsTable() bool

IsTable returns true if this object represent information for table, false for view.

func (*StructInfo) PKField Uses

func (s *StructInfo) PKField() FieldInfo

PKField returns a primary key field, panics for views.

Package parse imports 7 packages (graph) and is imported by 12 packages. Updated 2018-07-23. Refresh now. Tools for package owners.