gogenerator

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBinding

func NewBinding() (*astReader, error)

Types

type Entity

type Entity struct {
	*binding.Object

	Fields []*Field // the tree of struct fields (necessary for embedded structs)
	// contains filtered or unexported fields
}

Entity holds the model information necessary to generate the binding code

func (*Entity) HasLazyLoadedRelations

func (entity *Entity) HasLazyLoadedRelations() bool

HasLazyLoadedRelations called from the template.

func (*Entity) HasNonIdProperty

func (entity *Entity) HasNonIdProperty() bool

HasNonIdProperty called from the template. The goal is to void GO error "variable declared and not used"

func (*Entity) HasRelations

func (entity *Entity) HasRelations() bool

HasRelations called from the template.

func (*Entity) Merge

func (entity *Entity) Merge(mEntity *model.Entity) model.EntityMeta

Merge implements model.EntityMeta interface

type Field

type Field struct {
	Entity             *Entity // parent entity
	Name               string
	Type               string
	IsPointer          bool
	Property           *Property                 // nil if it's an embedded struct
	Fields             []*Field                  // inner fields, nil if it's a property
	StandaloneRelation *model.StandaloneRelation // to-many relation stored as a standalone relation in the model
	IsLazyLoaded       bool                      // only standalone (to-many) relations currently support lazy loading
	Meta               *Field                    // self reference for recursive ".Meta.Fields" access in the template
	// contains filtered or unexported fields
}

Field is a field in an entity-struct. Not all fields become properties (e.g. to-many relations don't have a property)

func (*Field) HasLazyLoadedRelations

func (field *Field) HasLazyLoadedRelations() bool

HasLazyLoadedRelations called from the template.

func (*Field) HasPointersInPath

func (field *Field) HasPointersInPath() bool

HasPointersInPath checks whether there are any pointer-based fields in the path. Called from the template.

func (*Field) HasRelations

func (field *Field) HasRelations() bool

HasRelations called from the template.

func (*Field) Path

func (field *Field) Path() string

Path returns full path to the field (in embedded struct) called from the template

type GoGenerator

type GoGenerator struct {
	ByValue bool
	// contains filtered or unexported fields
}

func (*GoGenerator) BindingFiles added in v0.10.0

func (gen *GoGenerator) BindingFiles(forFile string, options generator.Options) []string

BindingFiles returns names of binding files for the given entity file.

func (GoGenerator) IsGeneratedFile

func (GoGenerator) IsGeneratedFile(file string) bool

func (GoGenerator) IsSourceFile added in v0.12.0

func (GoGenerator) IsSourceFile(file string) bool

func (*GoGenerator) ModelFile added in v0.9.1

func (gen *GoGenerator) ModelFile(forFile string, options generator.Options) string

ModelFile returns the model GO file for the given JSON info file path

func (*GoGenerator) ParseSource

func (goGen *GoGenerator) ParseSource(sourceFile string) (*model.ModelInfo, error)

func (*GoGenerator) WriteBindingFiles

func (goGen *GoGenerator) WriteBindingFiles(sourceFile string, options generator.Options, mergedModel *model.ModelInfo) error

func (*GoGenerator) WriteModelBindingFile

func (goGen *GoGenerator) WriteModelBindingFile(options generator.Options, modelInfo *model.ModelInfo) error

type Property

type Property struct {
	*binding.Field

	IsBasicType bool
	GoType      string
	FbType      string
	Converter   *string

	// type casts for named types
	CastOnRead  string
	CastOnWrite string

	GoField *Field // actual code field this property represents
	Entity  *Entity
	// contains filtered or unexported fields
}

Property represents a mapping between a struct field and a DB field

func (*Property) AnnotatedType

func (property *Property) AnnotatedType() string

AnnotatedType returns "type" annotation value

func (*Property) Merge

func (property *Property) Merge(mProperty *model.Property) model.PropertyMeta

Merge implements model.PropertyMeta interface

func (*Property) ObTypeString

func (property *Property) ObTypeString() string

ObTypeString is called from the template

func (*Property) Path

func (property *Property) Path() string

Path is called from the template. It returns full path to the property (in embedded struct).

func (*Property) TplReadValue

func (property *Property) TplReadValue(objVar, castType string) string

TplReadValue returns a code to read the property value on a given object.

func (*Property) TplSetAndReturn

func (property *Property) TplSetAndReturn(objVar, castType, rhs string) string

TplSetAndReturn returns a code to write the property value on a given object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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