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 ¶
- func DefaultParsing(node *data.TypeNode, typ reflect.Type)
- func Parse(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func ParseArray(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func ParseBuiltin(node *data.TypeNode, pkg string, typ reflect.Type)
- func ParseFunc(node *data.TypeNode, typ reflect.Type, pkg string)
- func ParseInterface(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func ParseMap(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func ParsePointer(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func ParseSlice(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func ParseStructure(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func StructFieldsEqual(node *data.TypeNode, typ reflect.Type, pkg string, ...)
- func TypeAlreadyVisited(typ reflect.Type, fqnTypesProcessed map[string]struct{}) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultParsing ¶
DefaultParsing sets the common metadata for a TypeNode from a reflect.Type. This includes type name, package path, packaged type string, comparability, availability of Equal/Diff methods, and package alias handling.
func Parse ¶
func Parse(node *data.TypeNode, typ reflect.Type, pkg string, fqnTypesProcessed map[string]struct{})
Parse recursively analyzes the given reflect.Type and fills the provided TypeNode with its structural and metadata information.
node: the current TypeNode to populate typ: the reflect.Type being parsed pkg: the package of the parent referer fqnTypesProcessed: map to track already parsed types (avoiding recursion loops)
func ParseArray ¶
func ParseArray(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
ParseArray handles fixed-length array types. It parses the element type recursively.
func ParseBuiltin ¶
ParseBuiltin handles built-in Go types (string, int, bool, etc.). It sets the node kind to Builtin and determines if the type belongs to the same package.
func ParseInterface ¶
func ParseInterface(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
ParseInterface handles interface types. It marks the node as an interface, sets SamePkgAsReferer.
func ParseMap ¶
func ParseMap(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
ParseMap handles map types. It parses both the key type and value type recursively and merges their imports.
func ParsePointer ¶
func ParsePointer(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
ParsePointer handles pointer types. It parses the pointed-to type recursively and inherits its packaged type and imports.
func ParseSlice ¶
func ParseSlice(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
ParseSlice handles slice types. It parses the element type recursively and tracks whether it's in the same package.
func ParseStructure ¶
func ParseStructure(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
ParseStructure analyzes a struct type and fills the corresponding TypeNode.
- Marks the node as kind Struct.
- Sets SamePkgAsReferer to indicate whether the struct belongs to the same package as the one where parsing is initiated.
- Initializes the imports map if the struct comes from a different package.
- Skips re-processing types that have already been visited (tracked in typesProcessed).
- If the struct does not have a custom Equal method, its fields are analyzed to generate equality logic.
- Finally, Err is set to true only if the struct has no custom Equal method and all its fields also have Err set to true.
func StructFieldsEqual ¶
func StructFieldsEqual(node *data.TypeNode, typ reflect.Type, pkg string, typesProcessed map[string]struct{})
StructFieldsEqual parses the fields of a struct for equality/diff generation. It skips certain predefined meta types and parses each remaining field recursively.
func TypeAlreadyVisited ¶
TypeAlreadyVisited checks if a type has already been processed in the current parsing context. It prevents infinite recursion when parsing self-referential or cyclic types.
typ: the reflect.Type to check fqnTypesProcessed: a map storing fully-qualified names (package + type) of already parsed types returns true if the type was already visited, false otherwise
Types ¶
This section is empty.