Documentation
¶
Overview ¶
Copyright 2025 HAProxy Technologies LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func ApplyTemplateForDiff(node *TypeNode, ctx *Ctx, t *template.Template)
- func ApplyTemplateForEqual(node *TypeNode, ctx *Ctx, t *template.Template)
- func GetTemplateDataFromSubNodeDiff(node *TypeNode, ctx *Ctx) map[string]string
- func GetTemplateDataFromSubNodeEqual(node *TypeNode, ctx *Ctx) map[string]string
- func GetTypeFromNode(node *TypeNode) string
- func KindToString(kind Kind) string
- type Ctx
- type Kind
- type TypeNode
Constants ¶
const ( ParameterTypeDataMap = "ParameterType" // Full type string for parameter EqualFuncNameDataMap = "EqualFuncName" // Name of the Equal function EqualityTestDataMap = "EqualityTest" // Expression for equality comparison InequalityTestDataMap = "InequalityTest" // Expression for inequality comparison DiffFuncNameDataMap = "DiffFuncName" // Name of the Diff function DiffElementMap = "DiffElement" // Expression for diffing NodeNameMap = "NodeName" // Field name IsBuiltinSubNodeMap = "IsBuiltinSubNode" // Indicates if sub-node is a builtin type SubTypeMap = "SubType" // Type of sub-node )
Constants used as keys when passing template data to Equal/Diff templates
Variables ¶
This section is empty.
Functions ¶
func ApplyTemplateForDiff ¶
ApplyTemplateForDiff applies a text/template to generate the Diff function for the given node, storing the result in ctx.
func ApplyTemplateForEqual ¶
ApplyTemplateForEqual applies a text/template to generate the Equal function for the given node, storing the result in ctx.
func GetTemplateDataFromSubNodeDiff ¶
GetTemplateDataFromSubNodeDiff prepares template variables for generating Diff function
func GetTemplateDataFromSubNodeEqual ¶
GetTemplateDataFromSubNodeEqual prepares template variables for generating Equal function
func GetTypeFromNode ¶
GetTypeFromNode returns the string representation of a type node
func KindToString ¶
KindToString converts a Kind enum to a string
Types ¶
type Ctx ¶
type Ctx struct {
PkgPath string
Pkg string
ObjectNameToHaveGeneration string
LeftSideComparison, RightSideComparison string
EqualImplementation string
InequalImplementation string
DiffImplementation string
EqualFuncName string
DiffFuncName string
DiffElement string
ObjectKind string
Type string
Imports map[string]struct{}
Err bool
DefinedType bool
SubCtxs []*Ctx
}
Ctx holds information needed for code generation
type Kind ¶
type Kind int
Kind represents the kind of a type node (builtin, struct, array, slice, map, etc.)
func (Kind) MarshalJSON ¶
MarshalJSON allows Kind to be serialized to JSON as a string
func (Kind) MarshalYAML ¶
MarshalYAML allows Kind to be serialized to YAML as a string
type TypeNode ¶
type TypeNode struct {
HasEqual bool // True if type has an existing Equal method
HasEqualOpts bool // True if type has an existing Equal method with options
HasDiff bool // True if type has an existing Diff method
HasDiffOpts bool // True if type has an existing Diff method with options
Name string // Field name, empty for root type
Type string // Field type name
PackagedType string // Fully qualified type name including package
Kind Kind // Kind of the type
IsComparable bool // True if type can be compared with ==
PkgPath string // Package path for the type
PkgAlias string // Alias used when importing the package
SamePkgAsReferer bool // True if type is in same package as reference
Fields []*TypeNode // Child fields (for structs)
Len int // Array length
Value *reflect.Value // Optional pointer to value
Imports map[string]struct{}
MapKeyType string
SubNode *TypeNode
UpNode *TypeNode `json:"-"`
Err bool
}
TypeNode represents a type or field in the type hierarchy
func (*TypeNode) IsForField ¶
IsForField returns true if this node represents a field