code

package
v0.1.1-0...-cbd2f86 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package code provides functions for preparing data for code generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldTmpl

type FieldTmpl struct {
	Index      uint64
	FieldName  string
	FieldType  string
	IsSlice    bool
	IsEmbedded bool
}

FieldTmpl has data for template struct field.

type FuncCallTmpl

type FuncCallTmpl struct {
	Index uint64

	CalleeName string
	FieldName  string
	FieldType  string
	IsSlice    bool

	IsSupportedType bool
	ParserName      string

	IsEmbedded   bool
	EmbeddedType string

	ImplementsStringParser bool
	ImplementsConfigLoader bool

	ConfigKey    string
	HasConfigKey bool

	DefaultValue    string
	HasDefaultValue bool
}

FuncCallTmpl has data for template function call.

type FuncDefTmpl

type FuncDefTmpl struct {
	FuncName       string
	ReturnTypeName string
	Calls          []FuncCallTmpl
}

FuncDefTmpl has data for template function definition.

type ImportTmpl

type ImportTmpl struct {
	Path string
	Name string
}

ImportTmpl has data for template import.

type PrepareError

type PrepareError struct {
	StructPath []string
	Cause      error
}

PrepareError may occur when preparing data for the template.

func (*PrepareError) Error

func (e *PrepareError) Error() string

Error implements error.

type StructDefTmpl

type StructDefTmpl struct {
	StructName string
	Fields     []FieldTmpl
}

StructDefTmpl has data for template struct definition.

type TmplState

type TmplState struct {
	PkgPath    string
	PkgName    string
	TypeName   string
	Entrypoint string

	Imports []ImportTmpl

	SharedPkgName string
	CorePkgName   string

	StructDefs []StructDefTmpl
	FuncDefs   []FuncDefTmpl
}

TmplState has data for code template.

func PrepareTemplate

func PrepareTemplate(root *structure.StructType, pkg *packages.Package) (*TmplState, error)

PrepareTemplate prepares data for code template.

Jump to

Keyboard shortcuts

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