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 AliasImport(importPath string) string
- func AliasPkg(pkg string) string
- func DiffFuncName(input string) string
- func EqualFuncName(input string) string
- func ExtractPkg(fullpkg string) string
- func Fqn(packagedName string) string
- func GenerateAliasVarName(packagedType string) string
- func HasDiffFor(typ reflect.Type) (hasDiff bool, hasDiffWithOpts bool)
- func HasEqualFor(typ reflect.Type) (hasEqual bool, hasEqualWithOpts bool)
- func SerializeJSON[T any](node T) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AliasImport ¶
AliasImport applies AliasPkg to the last path segment of an import path.
func AliasPkg ¶
AliasPkg converts a package name to a valid Go import alias. - Replaces hyphens with underscores. - If the name starts with a digit, prefixes it with an underscore. - Returns an empty string if no alias is necessary.
func DiffFuncName ¶
DiffFuncName returns the generated Diff function name for a given type name.
func EqualFuncName ¶
EqualFuncName returns the generated Equal function name for a given type name.
func ExtractPkg ¶
ExtractPkg returns the last element of a full Go import path, which corresponds to the package name (e.g., "github.com/foo/bar" -> "bar").
func Fqn ¶
Fqn generates a "Fully Qualified Name"-like string from a Go type name, transforming it into a form suitable for use in generated function names. It handles slices, arrays, and pointers by replacing symbols with descriptive words (e.g., []MyType -> SliceMyType, **MyType -> PointerPointerMyType).
func GenerateAliasVarName ¶
GenerateAliasVarName converts a packaged type name like "models.Backend" or "v1.Backend" into a variable-safe Go identifier like "modelsBackend" or "v1Backend". Non-letter and non-digit characters are removed.
func HasDiffFor ¶
HasDiffFor checks whether a given type defines a Diff method with the exact signature: func (T) Diff(T) map[string][]interface{} or func (T) Diff(T, opts ...GoMethodGenOptions) map[string][]interface{}.
func HasEqualFor ¶
HasEqualFor checks whether a given type defines an Equal method with the exact signature: func (T) Equal(T) bool or func (T) Equal(T, opts ...GoMethodGenOptions) bool
func SerializeJSON ¶
SerializeJSON serializes any Go value to a pretty-printed JSON string. If serialization fails, the program will log a fatal error and exit.
Types ¶
This section is empty.