wrapper

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeneratorOpts

type GeneratorOpts struct {
	// FormatImports, if set to true, will be used
	// call imports.Process
	FormatImports bool

	// Template will be used to generate the wrapper
	// If this is null TemplateStr or TemplatePath
	// will be used.
	Template *template.Template

	// TemplateStr will be used to generate the wrapper
	// If this is null Template or TemplatePath
	// will be used.
	TemplateStr string

	// TemplatePath will be used to generate the wrapper
	// The code will first read the contents. If this is
	// null Template or TemplateStr will be used.
	// TODO can this be a directory?
	TemplatePath string

	// Suffix will be used to name the generated wrapper.
	// GOFILE.Suffix.go. By default promwrapgen will be used.j
	Suffix string

	// Metrics will be used to decided what metrics to include.
	// Possible values are:
	// 1. duration
	// 2. total
	// 3. error
	// 4. success
	// 5. all
	// If all is specified then others will be ignored.
	Metrics types.Strings
}

TODO how can we go about using multiple template files

type TemplateVals

type TemplateVals struct {
	PackageName     string
	WrapperTypeName string
	MethodList      []types.Method
	Imports         string
	StartTimeName   string
	DurationName    string
	RandomHex       string

	// metrics
	HasDuration bool
	HasTotal    bool
	HasError    bool
	HasSuccess  bool
}

type TypeVisitor

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

func NewTypeVisitor

func NewTypeVisitor(g *WrapperGenerator, opts TypeVisitorOpts) (*TypeVisitor, error)

func (*TypeVisitor) Visit

func (t *TypeVisitor) Visit(nRaw ast.Node) ast.Visitor

func (*TypeVisitor) Walk

func (t *TypeVisitor) Walk() error

type TypeVisitorOpts

type TypeVisitorOpts struct {
	CWD      string
	FileName string
	Targets  types.Strings
}

type WrapperGenerator

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

func MustNewWrapperGenerator

func MustNewWrapperGenerator(w *WrapperGenerator, err error) *WrapperGenerator

func NewWrapperGenerator

func NewWrapperGenerator(opts GeneratorOpts) (*WrapperGenerator, error)

func (*WrapperGenerator) Generate

func (w *WrapperGenerator) Generate(outPath, filename string, tmplVals TemplateVals) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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