es_generate

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorTargetInterfaceNotFound = errors.New("the target interface is not found in the source tree")
)

Functions

func UniqSortedPackages

func UniqSortedPackages(sts []*StructType) []string

Types

type Generator

type Generator interface {
	// Generate source with templateName
	Generate(tmplName string) (src []byte, err error)
}

func NewStructTypeGenerator

func NewStructTypeGenerator(ctl app_control.Control, sts []*StructType) Generator

type Scanner

type Scanner interface {
	// Find struct which implements the given interface.
	// Please pass the type `t` as like reflect.TypeOf((*INTERFACE_PKG.INTERFACE)(nil)).Elem()
	FindStructImplements(refType reflect.Type) ([]*StructType, error)

	// Find struct which has name starts from prefix.
	FindStructHasPrefix(prefix string) ([]*StructType, error)

	// Exclude `*_test.go` files.
	ExcludeTest() Scanner

	// Limit path with prefix
	PathFilterPrefix(prefix string) Scanner
}

func NewScanner

func NewScanner(c app_control.Control, path string) (Scanner, error)

type StructType

type StructType struct {
	// Relative package path from the scan root.
	Package string `json:"package"`

	// Name of the struct type.
	Name string `json:"name"`
}

func SortedStructTypes

func SortedStructTypes(sts []*StructType) (sorted []*StructType)

Jump to

Keyboard shortcuts

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