generator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Version   string
	Revision  string
	BuildDate string
	BuiltBy   string
	// contains filtered or unexported fields
}

Generator is responsible for generating validation files for the given in a go source file.

func NewGenerator

func NewGenerator() *Generator

NewGenerator creates new Generator

func (*Generator) Generate

func (g *Generator) Generate(node *ast.File) ([]byte, error)

Generate is responsible for orchestrating the code generation process.

func (*Generator) GenerateFromFile

func (g *Generator) GenerateFromFile(inputFile string) ([]byte, error)

GenerateFromFile is responsible for orchestrating the Code generation. It results in a byte array that can be written to any file desired.

func (*Generator) WithBuildTags

func (g *Generator) WithBuildTags(tags ...string) *Generator

WithBuildTags will add build tags to the generated file.

type Struct

type Struct struct {
	Name   string
	Views  []string
	Fields []StructField
}

Struct describes one struct

func NewStructList

func NewStructList(node *ast.File) []Struct

NewStructList creates a list of Struct from the provided ast.File node.

type StructField

type StructField struct {
	Name string
	Type string
	Tag  *StructTag
}

StructField describes one field on struct

type StructTag

type StructTag map[string]string

StructTag describes tag value for each view, default view has * key

func NewStructTagFromString

func NewStructTagFromString(sourceTag string) *StructTag

NewStructTagFromString creates StructTag from source struct tag

Jump to

Keyboard shortcuts

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