data

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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

func ApplyTemplateForDiff(node *TypeNode, ctx *Ctx, t *template.Template)

ApplyTemplateForDiff applies a text/template to generate the Diff function for the given node, storing the result in ctx.

func ApplyTemplateForEqual

func ApplyTemplateForEqual(node *TypeNode, ctx *Ctx, t *template.Template)

ApplyTemplateForEqual applies a text/template to generate the Equal function for the given node, storing the result in ctx.

func GetTemplateDataFromSubNodeDiff

func GetTemplateDataFromSubNodeDiff(node *TypeNode, ctx *Ctx) map[string]string

GetTemplateDataFromSubNodeDiff prepares template variables for generating Diff function

func GetTemplateDataFromSubNodeEqual

func GetTemplateDataFromSubNodeEqual(node *TypeNode, ctx *Ctx) map[string]string

GetTemplateDataFromSubNodeEqual prepares template variables for generating Equal function

func GetTypeFromNode

func GetTypeFromNode(node *TypeNode) string

GetTypeFromNode returns the string representation of a type node

func KindToString

func KindToString(kind Kind) string

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.)

const (
	Unknown Kind = 1 << iota
	Builtin
	Struct
	Array
	Slice
	Map
	Interface
	Pointer
	Func
)

func (Kind) MarshalJSON

func (k Kind) MarshalJSON() ([]byte, error)

MarshalJSON allows Kind to be serialized to JSON as a string

func (Kind) MarshalYAML

func (k Kind) MarshalYAML() (interface{}, error)

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

func (en *TypeNode) IsForField() bool

IsForField returns true if this node represents a field

func (*TypeNode) IsForType

func (en *TypeNode) IsForType() bool

IsForType returns true if this node represents a type (not a field)

Jump to

Keyboard shortcuts

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