gen

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 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 added in v0.6.1

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

func GenerateMarkdown

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

func Validate added in v0.5.1

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 added in v0.7.3

func (d Decl) MessageIsErrTemplate() string

func (Decl) MessageNewErrTemplate added in v0.7.3

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 added in v0.6.1

type Option func(*Setting)

func DefaultErrorLevel added in v0.6.1

func DefaultErrorLevel(level reguerr.Level) Option

func DefaultStatusCode added in v0.6.1

func DefaultStatusCode(code int) Option

type Setting added in v0.6.1

type Setting struct {
	Level      reguerr.Level
	StatusCode int
}

func NewSetting added in v0.6.1

func NewSetting() *Setting

func (Setting) EnableInit added in v0.6.1

func (o Setting) EnableInit() bool

func (Setting) IsOverwriteErrorLevel added in v0.6.1

func (o Setting) IsOverwriteErrorLevel() bool

func (Setting) IsOverwriteStatusCode added in v0.6.1

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