gen

package
v0.0.0-...-d874ebc Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectGoType

func DetectGoType(expr ast.Node) string

func GenerateCode

func GenerateCode(f *File, opts ...Option) ([]byte, error)

func GenerateMarkdown

func GenerateMarkdown(w io.Writer, decls []*Decl, opts ...Option) error

func Validate

func Validate(decls []*Decl) error

Check unique message code

Types

type Decl

type Decl struct {
	Name             string
	Code             string
	Format           string
	LogLevelEnable   bool
	LogLevel         reguerr.Level
	StatusCodeEnable bool
	StatusCode       int
	DisableErr       bool
	Labels           []Label

	CallBuild bool
	// contains filtered or unexported fields
}

func (Decl) ArgValues

func (d Decl) ArgValues() string

func (Decl) Args

func (d Decl) Args() string

func (Decl) ExistArgs

func (d Decl) ExistArgs() bool

func (Decl) MessageIsErrTemplate

func (d Decl) MessageIsErrTemplate() string

func (Decl) MessageNewErrTemplate

func (d Decl) MessageNewErrTemplate() string

type File

type File struct {
	PkgName string
	Decls   []*Decl
}

func Traverse

func Traverse(n *ast.File) (*File, error)

type Label

type Label struct {
	Index  int
	Name   string
	GoType string
}

type Option

type Option func(*Setting)

func DefaultErrorLevel

func DefaultErrorLevel(level reguerr.Level) Option

func DefaultStatusCode

func DefaultStatusCode(code int) Option

type Setting

type Setting struct {
	Level      reguerr.Level
	StatusCode int
}

func NewSetting

func NewSetting() *Setting

func (Setting) EnableInit

func (o Setting) EnableInit() bool

func (Setting) IsOverwriteErrorLevel

func (o Setting) IsOverwriteErrorLevel() bool

func (Setting) IsOverwriteStatusCode

func (o Setting) IsOverwriteStatusCode() bool

type Verb

type Verb string

func Analyze

func Analyze(format string) []Verb

Jump to

Keyboard shortcuts

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