parse

package
v0.0.0-...-305e30f Latest Latest
Warning

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

Go to latest
Published: May 20, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertUpToDate

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.

Types

type FieldInfo

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
	Column string // SQL database column name from "reform:" struct field tag, e.g. name
}

FieldInfo represents information about struct field.

type StructInfo

type StructInfo struct {
	Type         string      // struct type as defined in source file, e.g. User
	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

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

File parses given file and returns found structs information.

func Object

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

Object extracts struct information from given object.

func (*StructInfo) Columns

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

Columns returns a new slice of column names.

func (*StructInfo) IsTable

func (s *StructInfo) IsTable() bool

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

func (*StructInfo) PKField

func (s *StructInfo) PKField() FieldInfo

PKField returns a primary key field, panics for views.

Jump to

Keyboard shortcuts

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