internal

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(m *StructMapping, goPackage string, goFile string, w io.Writer) (outputFilename string, err error)

Generate Go code for the struct mapping

Types

type FieldMapping

type FieldMapping struct {
	// Name is the Go field name
	Name string
	// ReadColDef is the read column definition (nil if not given)
	ReadColDef *ReadColDef
	// WriteColDef is the write column definition (nil if not given)
	WriteColDef *WriteColDef
	// FieldType is the type in the Go struct
	FieldType types.Type
}

FieldMapping contains mapping information for a field of a mapping

type ReadColDef

type ReadColDef struct {
	// Col is the column name
	Col string
	// Sortable is true, if the column should appear in the list of sortable columns
	Sortable bool
}

ReadColDef is the read column definition

type StructMapping

type StructMapping struct {
	// TargetName is the exported record name (e.g. "MyRecord")
	TargetName string
	// MappingTypePackage is the package of the type with mapping information
	MappingTypePackage string
	// MappingTypePackage is the name of the type with mapping information
	MappingTypeName string
	// TableName contains the table name (if set)
	TableName string
	// FieldMappings contains all field mappings derived from the type
	FieldMappings []FieldMapping
}

StructMapping contains mapping information for a struct type

func BuildStructMapping

func BuildStructMapping(mappingTypePackage string, mappingTypeName string, targetTypeName string) (*StructMapping, error)

BuildStructMapping builds a struct mapping for a given mapping type and target type

func DiscoverStructMappings

func DiscoverStructMappings(mappingTypePackage string) (mappings []*StructMapping, err error)

DiscoverStructMappings discovers all struct mappings in a given package

type WriteColDef

type WriteColDef struct {
	// Col is the column name
	Col string
	// ToJSON when writing a column value
	ToJSON bool
}

WriteColDef is the write column definition

Directories

Path Synopsis
Code generated by construct, DO NOT EDIT.
Code generated by construct, DO NOT EDIT.
repository
Code generated by construct, DO NOT EDIT.
Code generated by construct, DO NOT EDIT.

Jump to

Keyboard shortcuts

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