utils

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package utils provides utility functions for handling common tasks such as setting default values, checking 'zero-ness', and normalizing map keys. Includes string comparison functions and map merging functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepMergeMapsWithoutOverwrite

func DeepMergeMapsWithoutOverwrite(first, second map[string]any)

DeepMergeMapsWithoutOverwrite merges two maps of map[string]any, adding values from second to first without overwriting the existing values in first. It performs a deep merge, handling nested maps recursively.

func IsURL

func IsURL(str string) bool

IsURL checks if the input string is a valid URL.

func IsZeroValue added in v0.0.1

func IsZeroValue[S comparable](input S) bool

IsZeroValue checks if the input value is its zero value.

func NormalizeMap

func NormalizeMap(m map[string]any) map[string]any

NormalizeMap normalizes the keys of a map to title case recursively. If the value is another map, it will recursively normalize its keys as well.

func SetIfZeroValue added in v0.0.1

func SetIfZeroValue[S comparable](input *S, value S)

SetIfZeroValue sets the value of input to the specified value if it is its zero value.

func SetMapIfNil

func SetMapIfNil[M ~map[K]V, K comparable, V any](input *M, values M)

SetMapIfNil sets the value of input to the provided defaultMap if input is nil.

func SetSliceIfNil

func SetSliceIfNil[S ~[]T, T any](input *S, values ...T)

SetSliceIfNil sets the value of input to the provided values slice if input is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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