common

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GeneratedSrcFileExt      GeneratedExtension = ".gen.go"
	GeneratedTestFileExt     GeneratedExtension = ".gen_test.go"
	GeneratedCommentTemplate string             = "autoGenComment"
	AutoGeneratedTemplate    string             = "// Code generated by {{ .GeneratorName }} - DO NOT EDIT."
)
View Source
const (
	GeneratorCommentPrefix string = "gen"
)

Variables

View Source
var (
	ArgParseExitOnFail bool = true
)
View Source
var CommentArgsMalformed = errors.New("Malformed comment arg.")
View Source
var InvalidGeneratorFileName = errors.New("Invalid generator file name.")
View Source
var MissingRequiredArgs = errors.New("Not all required flags were passed.")
View Source
var UnrecognizedArgs = errors.New("Unrecognized arguments were passed.")

Functions

func CleanFileName

func CleanFileName(fName string) string

func CommentArgs

func CommentArgs(globalStruct any, comment CommentArgVals) error

func DocArgsAstFilter

func DocArgsAstFilter(
	expectedType string,
	globalStruct any,
) (
	func(fSet *token.FileSet, srcFile *os.File, node ast.Node) error,
	*bool,
)

func GenFileExclusionFilter

func GenFileExclusionFilter(f fs.FileInfo) bool

func GetComment

func GetComment(
	fSet *token.FileSet,
	srcFile *os.File,
	doc *ast.CommentGroup,
	comment *ast.CommentGroup,
) (string, error)

func GetLongGenericsString

func GetLongGenericsString(
	fSet *token.FileSet,
	srcFile *os.File,
	ts *ast.TypeSpec,
) (string, error)

func GetProgName

func GetProgName(args []string) string

func GetShortGenericsString

func GetShortGenericsString(
	fSet *token.FileSet,
	srcFile *os.File,
	ts *ast.TypeSpec,
) (string, error)

func GetSourceTextFromExpr

func GetSourceTextFromExpr(
	fSet *token.FileSet,
	srcFile *os.File,
	field ast.Node,
) (string, error)

func InlineArgs

func InlineArgs(globalStruct any, args []string) error

func IterateOverAST

func IterateOverAST(
	path string,
	filter func(f fs.FileInfo) bool,
	op func(
		fSet *token.FileSet,
		file *ast.File,
		srcFile *os.File,
		node ast.Node,
	) bool,
)

func PrintRunningError

func PrintRunningError(fmtStr string, args ...any)

func PrintRunningInfo

func PrintRunningInfo(fmtStr string, args ...any)

Types

type CommentArgVals

type CommentArgVals map[string]string

func GetDocArgVals

func GetDocArgVals(
	fSet *token.FileSet,
	srcFile *os.File,
	doc *ast.CommentGroup,
) (CommentArgVals, error)

type GeneratedExtension

type GeneratedExtension string

type GeneratedFilesRegistry

type GeneratedFilesRegistry struct {
	template.Template
}

func NewGeneratedFilesRegistryFromMap

func NewGeneratedFilesRegistryFromMap(
	vals map[string]string,
) GeneratedFilesRegistry

func (*GeneratedFilesRegistry) WriteToFile

func (g *GeneratedFilesRegistry) WriteToFile(
	outFile string,
	extension GeneratedExtension,
	templateName string,
	data any,
) error

Jump to

Keyboard shortcuts

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