generator

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileImports

func GetFileImports(filePath string) ([]string, error)

GetFileImports read the file and parse the imports section. Return all found imports with aliases.

func RenderOptions

func RenderOptions(
	packageName, optionsStructName string,
	fileImports []string,
	spec *OptionSpec,
	tagName, varName, funcName, prefix string,
) ([]byte, error)

RenderOptions will render file and out it's content.

Types

type OptionMeta

type OptionMeta struct {
	Name      string
	Docstring string // contains a comment with `//`. Can be empty or contain a multi-line string.
	Field     string
	Type      string
	TagOption TagOption
}

type OptionSpec added in v0.15.0

type OptionSpec struct {
	TypeParamsSpec string // [KeyT int | string, TT any]
	TypeParams     string // [KeyT, TT]
	Options        []OptionMeta
}

func GetOptionSpec

func GetOptionSpec(filePath, optionsStructName, tagName string) (*OptionSpec, []string, error)

GetOptionSpec read the input filename by filePath, find optionsStructName and scan for options.

func (OptionSpec) HasValidation added in v0.15.0

func (s OptionSpec) HasValidation() bool

type TagOption

type TagOption struct {
	IsRequired  bool
	GoValidator string
	Default     string
}

Jump to

Keyboard shortcuts

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