particle

package module
v0.0.0-...-5b87da9 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 6 Imported by: 0

README

particle

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

func NewGenerator

func NewGenerator(opts GeneratorOpts) *Generator

NewGenerator creates a new generator configured by the given GeneratorOpts.

func (*Generator) AccessFunc

func (g *Generator) AccessFunc(typ *ast.TypeSpec, field *ast.Field, imp []*ast.ImportSpec)

AccessFunc generates the code for the function used to access a field.

func (*Generator) File

func (g *Generator) File(file *ast.File)

File generates the code for the entire file.

func (*Generator) Generate

func (g *Generator) Generate() string

Generate generates the code for the current file.

func (*Generator) Import

func (g *Generator) Import(imp *ast.ImportSpec)

Import generates the code for the given import spec.

func (*Generator) Imports

func (g *Generator) Imports(imp []*ast.ImportSpec)

Imports generates the code for the given import specs.

func (*Generator) Line

func (g *Generator) Line()

Line inserts an empty line into the generated code.

func (*Generator) Type

func (g *Generator) Type(typ *ast.TypeSpec)

Type generates a "partial" map-type.

func (*Generator) WithFunc

func (g *Generator) WithFunc(typ *ast.TypeSpec, field *ast.Field, imp []*ast.ImportSpec)

WithFunc generates the code for the function used to update a field.

type GeneratorOpts

type GeneratorOpts struct {
	// Package is the name of the package to generate the code in.
	Package string `json:"package,omitempty"`

	// StructTag is the name of the struct tag to use for accessing the value
	// of the field in the partial type's helper methods.
	StructTag string `json:"structTag,omitempty"`

	// TypePrefix is the prefix to use for the generated partial types.
	TypePrefix string `json:"typePrefix,omitempty"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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