gen

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gen generates codes for egbuilder.

Index

Constants

View Source
const (
	KindName = "Kind"
	SpecName = "Spec"
)

Variables

This section is empty.

Functions

func CreateController

func CreateController(name string) *j.File

func CreateFilter

func CreateFilter(name string) *j.File

func CreateRegistry

func CreateRegistry(config *Config) *j.File

func CreateServer

func CreateServer(plugins []string) *j.File

Types

type Config

type Config struct {
	Repo        string   `json:"repo"`
	Controllers []string `json:"controllers"`
	Filters     []string `json:"filters"`
}

Config is the configuration for generate files.

func (*Config) CheckDuplicate

func (c *Config) CheckDuplicate(conf *Config) error

CheckDuplicate checks if the config has duplicate controllers or filters.

func (*Config) GenControllers

func (c *Config) GenControllers(dir string) error

func (*Config) GenFilters

func (c *Config) GenFilters(dir string) error

func (*Config) GenRegistry

func (c *Config) GenRegistry(dir string) error

func (*Config) Load

func (c *Config) Load(dir string) error

Load loads the config from file.

func (*Config) Save

func (c *Config) Save(dir string) error

Save saves the config to file.

type Const

type Const struct {
	Name    string
	Value   interface{}
	Comment string
}

Const is a const definition.

type Consts

type Consts []*Const

func (Consts) Def

func (consts Consts) Def() *j.Statement

type ControllerInfo

type ControllerInfo struct {
	ReceiverName string
	Name         string
	LowerName    string
}

ControllerInfo is the information of a controller. Name: "TestFilter", used for struct name LowerName: "testfilter", used for file name, pkg name VarKind: "TestFilterKind", used for registry ResultFail: "resultTestFilterFail", used for result Most of these fields are used as identifier.

func NewControllerInfo

func NewControllerInfo(name string) *ControllerInfo

NewInfo creates a new Info.

type FilterInfo

type FilterInfo struct {
	ReceiverName string
	Name         string
	LowerName    string
	ResultFail   string
}

FilterInfo is the information of a filter.

func NewFilterInfo

func NewFilterInfo(name string) *FilterInfo

NewFilterInfo creates a new Info.

type Func

type Func struct {
	ReceiverName    string
	ReceiverType    string
	ReceiverPointer bool

	Name    string
	Params  []j.Code
	Returns []j.Code
	Block   []j.Code
}

Func is a function definition.

func (*Func) Def

func (fn *Func) Def() *j.Statement

Jump to

Keyboard shortcuts

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