gen

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interfaces

func Interfaces(tpl, out string) error

Interfaces generates the public interfaces for checker providers implementations in package check (provider_*.go files). It should be run every time their API is modified (method signature change, doc comment, new method, method removal, ...)

func Types

func Types(tpl, out string) error

Types generates checkers declarations in packages check and checkconv for each type defined in var `types`. It should be run every time this list is modified.

For instance, the following entry:

{N: "Int", T: "int"},

generates the following declarations:

// file check/check.go
type IntPassFunc func(got int) bool
type IntPasser interface { Pass(got int) bool }
type IntChecker interface { IntPasser; Explainer }

// file check/checkers.go
type intChecker struct { ... }
func (c intChecker) Pass(got int) bool { ... }
func NewIntChecker(passFunc IntPassFunc, explainFunc ExplainFunc) IntChecker { ... }

// file checkconv/assert.go
func FromInt(c check.IntChecker) check.ValueChecker { ... }
// also adds a case in checkconv.Assert:
	case check.IntChecker:
		return FromInt(c)

Types

type ProvidersMetaData

type ProvidersMetaData struct {
	Interfaces []metatype.Interface
	Vars       []metatype.Var
}

ProvidersMetaData is a representation of the parsed doc for providers files in package check. It is meant to be used as a data source for template providers.gotmpl.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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