postprocess

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRepoRoot

func FindRepoRoot() (string, error)

func Generated

func Generated(opts Options) error

func PathContains

func PathContains(elem ...string) func(path string) bool

Types

type FieldMatcher

type FieldMatcher func(path string, field *ast.Field) bool

func AllFields

func AllFields(matchers ...FieldMatcher) FieldMatcher

func FieldNamed

func FieldNamed(names ...string) FieldMatcher

func FieldTypeEquals

func FieldTypeEquals(typeExpr string) FieldMatcher

type Options

type Options struct {
	GenDir               string
	NestedImportPatterns []string
	RemoveFile           func(path string) (bool, string)
	Replacements         []Replacement
	AddJSONTags          bool
	Verbose              bool
}

type Replacement

type Replacement func(path, text string) string

func AddStructField

func AddStructField(match TypeMatcher, fieldName, fieldType, fieldTag string) Replacement

func EnsureNamedImports

func EnsureNamedImports(imports map[string]string) Replacement

func IfPath

func IfPath(match func(path string) bool, replacements ...Replacement) Replacement

func RegexReplaceAll

func RegexReplaceAll(re *regexp.Regexp, replacement string) Replacement

func Replace

func Replace(o, n string, c int) Replacement

func ReplaceAll

func ReplaceAll(o, n string) Replacement

func ReplaceFieldType

func ReplaceFieldType(match FieldMatcher, replacementType string) Replacement

func SetStructFields

func SetStructFields(match TypeMatcher, fields []StructFieldSpec) Replacement

func SetTypeExpr

func SetTypeExpr(match TypeMatcher, replacementType string) Replacement

type StructFieldSpec

type StructFieldSpec struct {
	Name string
	Type string
	Tag  string
}

type TypeMatcher

type TypeMatcher func(path string, typeSpec *ast.TypeSpec) bool

func AnyType

func AnyType(matchers ...TypeMatcher) TypeMatcher

func TypeNamed

func TypeNamed(names ...string) TypeMatcher

Jump to

Keyboard shortcuts

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