parse

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name     string // The name of the field.
	TypeName string //string representation of the Go Type of the field
	Tags     map[string]StructTag
}

Value represents a struct field

type File

type File struct {
	// contains filtered or unexported fields
}

File holds a single parsed file and associated data.

type Generator

type Generator struct {
	Buf bytes.Buffer // Accumulated output.
	// contains filtered or unexported fields
}

Generator holds the state of the analysis. Primarily used to buffer the output for format.Source.

func (*Generator) Prepare

func (g *Generator) Prepare(args []string)

func (*Generator) Print

func (g *Generator) Print(output string)

func (*Generator) Printf

func (g *Generator) Printf(format string, args ...interface{})

func (*Generator) Run

func (g *Generator) Run(pathArgs []string, typeName string, outputName string, genFn GeneratorFunc) error

Run parses the target package and generates the code, verifying the package before and after generation. pathArgs is a list of file paths, to either individual files or whole directories. typeName is the name of a struct we're working on. outputName is where the generated code should go. genFn is the most important part, and recieves all the meta info about the targeted Type

type GeneratorFunc

type GeneratorFunc func(typeName string, fields []Field, imports []Import)

The caller will send a function of this type to do all the actual modification of the target package

type Import

type Import struct {
	ImportedName string
}

type Package

type Package struct {
	// contains filtered or unexported fields
}

type StructTag

type StructTag struct {
	Name  string
	Value string
}

Jump to

Keyboard shortcuts

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