generator

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const PREFIX string = "vgen"

Variables

This section is empty.

Functions

func GenerateFile added in v0.0.6

func GenerateFile(fs *token.FileSet, filePath string, s, w *[]string)

GenerateFile parses a file and generates a new one in the same directory

Types

type Alias added in v0.0.4

type Alias struct {
	Name string
	Type string
}

type ArrayField added in v0.0.6

type ArrayField struct {
	Type FieldType
}

func (ArrayField) String added in v0.0.6

func (t ArrayField) String() string

type CustomField added in v0.0.6

type CustomField struct {
	Value string
}

func (CustomField) String added in v0.0.6

func (t CustomField) String() string

type Data

type Data struct {
	Pkg     string
	Types   []Struct
	Aliases []Alias
	Imports []Import
}

func GetFileData

func GetFileData(file *ast.File) (Data, error)

func (Data) CreateTemplate

func (d Data) CreateTemplate() ([]byte, error)

CreateTemplate uses Data class to generate a go file

func (*Data) UseImport

func (d *Data) UseImport(imp string)

UseImport compares import used in type and sets it to used Needed since all imports are stored in visitor, and some might not be used in vgen types

type FieldType

type FieldType interface {
	String() string
	// contains filtered or unexported methods
}

FieldType holds methods needed for template generation

type Import

type Import struct {
	Alias string
	Path  string
	Used  bool
}

type ImportedField added in v0.0.6

type ImportedField struct {
	Import string
	Type   CustomField
}

func (ImportedField) String added in v0.0.6

func (t ImportedField) String() string

type MapField added in v0.0.6

type MapField struct {
	KeyType   FieldType
	ValueType FieldType
}

func (MapField) String added in v0.0.6

func (t MapField) String() string

type PrimitiveField added in v0.0.6

type PrimitiveField struct {
	Value string
}

Data types

func (PrimitiveField) String added in v0.0.6

func (t PrimitiveField) String() string

String functions

type Struct added in v0.0.6

type Struct struct {
	Name   string
	Fields []StructField
}

Struct is used to generate template

type StructField added in v0.0.6

type StructField struct {
	Pointer bool
	Name    string
	Type    FieldType
}

StructField is used to generate template

func (StructField) BaseType added in v0.0.6

func (f StructField) BaseType() FieldType

Used to generate template

func (StructField) Convert added in v0.0.6

func (f StructField) Convert() string

Convert is used to generate template

func (StructField) In added in v0.0.6

func (f StructField) In() string

Used to generate template

func (StructField) LowercaseName added in v0.0.6

func (f StructField) LowercaseName() string

LowercaseName is used to generate template

func (StructField) Rule added in v0.0.6

func (f StructField) Rule() string

Rule is used to generate template

func (StructField) String added in v0.0.6

func (f StructField) String() string

String is used to generate template

Jump to

Keyboard shortcuts

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