toolx

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownCamundaVersion = errors.New("unknown Camunda version")

Functions

func CopyMap added in v0.1.64

func CopyMap[K comparable, V any](in map[K]V) map[K]V

CopyMap returns a shallow copy of in (nil-safe).

func CopyPtr

func CopyPtr[T any](p *T) *T

CopyPtr returns a new pointer with the same value, or nil if input is nil.

func Deref

func Deref[T any](p *T, def T) T

Deref returns the value pointed to by p, or def if p is nil.

func DerefMap

func DerefMap[S any, D any](p *S, f func(S) D, def D) D

DerefMap pointer to value using mapper and default

func DerefSlice

func DerefSlice[T any](p *[]T) []T

DerefSlice returns a copy of the slice pointed to by p, or nil if p is nil.

func DerefSlicePtr

func DerefSlicePtr[S any, D any](p *[]S, f func(S) D) []D

DerefSlicePtr maps *[]S -> []D

func DerefSlicePtrE

func DerefSlicePtrE[S any, D any](p *[]S, f func(S) (D, error)) ([]D, error)

DerefSlicePtrE maps *[]S -> []D using f(S) (D, error). Returns nil, nil if p is nil.

func DetermineNoOfWorkers added in v0.1.71

func DetermineNoOfWorkers(jobsCount, wantedWorkersCount int) int

func Int64PtrToString

func Int64PtrToString(p *int64) string

Int64PtrToString converts *int64 → string, returns "" if nil.

func Int64PtrToStringPtr

func Int64PtrToStringPtr(p *int64) *string

Int64PtrToStringPtr maps *int64 -> *string using strconv.FormatInt. Returns nil if input is nil.

func Int64ToString

func Int64ToString(v int64) string

Int64ToString converts int64 → string.

func JSON

func JSON(w io.Writer, v any) error

JSON writes v as pretty-printed JSON to io.Writer

func MapMap

func MapMap[K comparable, S any, D any](in map[K]S, f func(S) D) map[K]D

MapMap maps a map’s values to a new map with the same keys.

func MapNullable

func MapNullable[T, U any](n nullable.Nullable[T], f func(T) U) (*U, error)

MapNullable maps a nullable.Nullable[T] to *U using f. Returns nil when the field is unspecified OR explicitly null. Propagates Get() errors from the nullable package.

func MapNullableSlice

func MapNullableSlice[S, D any](n nullable.Nullable[[]S], f func(S) D) (*[]D, error)

MapNullableSlice maps a nullable.Nullable[[]S] to *[]D using f for elements. Returns nil when the field is unspecified OR explicitly null.

func MapNullableSliceV

func MapNullableSliceV[S, D any](n nullable.Nullable[[]S], f func(S) D) ([]D, error)

MapNullableSliceV maps a nullable slice to a []D; returns nil (or empty) for unspecified/null.

func MapNullableV

func MapNullableV[T, U any](n nullable.Nullable[T], f func(T) U, def U) (U, error)

MapNullableV maps a nullable field to a value using f; returns def for unspecified or null.

func MapPtr

func MapPtr[S, D any](p *S, f func(S) D) *D

MapPtr applies f to *S and returns *D (nil-safe).

func MapSlice

func MapSlice[S any, D any](in []S, f func(S) D) []D

MapSlice maps []S -> []D using f.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to a copy of v (for value -> *T).

func PtrCopyMap added in v0.1.64

func PtrCopyMap[K comparable, V any](in map[K]V) *map[K]V

PtrCopyMap returns a pointer to a new shallow copy of in. Nil-safe. Uses CopyMap.

func PtrIf

func PtrIf[T comparable](v, zero T) *T

PtrIf returns a pointer to v if v != zero, otherwise nil. T must be comparable (e.g. not slices, maps, funcs). Examples: PtrIf("", "") -> nil PtrIf("x", "") -> *"x" PtrIf(int64(0), int64(0)) -> nil

func PtrIfNonEmptyMap added in v0.1.64

func PtrIfNonEmptyMap[K comparable, V any](m map[K]V) *map[K]V

PtrIfNonEmptyMap returns *map when m has at least one entry, otherwise nil. The pointer is to a copy of the map header, not a deep copy.

func PtrIfNonEmptySlice added in v0.1.64

func PtrIfNonEmptySlice[T any](s []T) *[]T

PtrIfNonEmptySlice returns *[]T when s has at least one element, otherwise nil.

func PtrIfNonZero

func PtrIfNonZero[T ~int | ~int32 | ~int64](v T) *T

PtrIfNonZero returns a pointer to v if v != 0, otherwise nil.

func StringPtrToInt64

func StringPtrToInt64(p *string) (int64, error)

StringPtrToInt64 converts *string → int64 (0 if nil), error if parsing fails.

func StringPtrToInt64Ptr

func StringPtrToInt64Ptr(p *string) (*int64, error)

StringPtrToInt64Ptr converts *string → *int64. Returns nil if input is nil, error if parsing fails.

func StringToInt32Ptr added in v0.1.71

func StringToInt32Ptr(s string) (*int32, error)

func StringToInt64

func StringToInt64(s string) (int64, error)

StringToInt64 converts string → int64, returns error if not parsable.

func StringToInt64Ptr

func StringToInt64Ptr(s string) (*int64, error)

StringToInt64Ptr converts string → *int64, returns nil if empty, error if invalid.

func SupportedCamundaVersionsString

func SupportedCamundaVersionsString() string

func ToJSONString

func ToJSONString(v any) string

ToJSONString returns v as a pretty-printed JSON string.

func UniqueSlice added in v0.1.71

func UniqueSlice[T comparable](in []T) []T

UniqueSlice returns a new slice with duplicates removed, order preserved.

Types

type CamundaVersion

type CamundaVersion string
const (
	V87 CamundaVersion = "8.7"
	V88 CamundaVersion = "8.8"
	V89 CamundaVersion = "8.9"

	CurrentCamundaVersion = V88
)

func NormalizeCamundaVersion

func NormalizeCamundaVersion(s string) (CamundaVersion, error)

func SupportedCamundaVersions

func SupportedCamundaVersions() []CamundaVersion

func (CamundaVersion) FilePrefix added in v0.1.67

func (v CamundaVersion) FilePrefix() string

func (CamundaVersion) String

func (v CamundaVersion) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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