value

package module
v1.173.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

* Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

* Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmpty

func IsEmpty(value any) bool

IsEmpty checks whether a value is empty i.e. "", nil, 0, [], {}, false, etc. For Strings, a string is considered empty if it is "" or if it only contains whitespaces

func IsNilInterface

func IsNilInterface(i any) bool

IsNilInterface checks whether an interface value is nil even when it has been passed around as `any`.

func IsNotEmpty

func IsNotEmpty(value any) bool

IsNotEmpty checks whether a value is not empty. See IsEmpty for more details about what is considered empty.

Types

type IValueConverter

type IValueConverter interface {
	ConvertValue(ctx context.Context, value any) (any, error)
}

IValueConverter converts a value before it is consumed by a caller.

Implementations may use ctx to observe cancellation, access request-scoped metadata, or carry other conversion-time state. The returned value replaces the original input. A non-nil error reports that conversion failed and should usually stop the caller's processing.

var IdentityConverter IValueConverter = ValueConverterFunc(func(_ context.Context, value any) (any, error) {
	return value, nil
})

IdentityConverter returns values unchanged.

It ignores ctx and always succeeds.

var StringConverter IValueConverter = ValueConverterFunc(func(_ context.Context, value any) (any, error) {
	return stringifyValue(value)
})

StringConverter converts values to strings.

Nil interface and pointer values are rendered as `<nil>`. For non-nil values, it prefers fmt.Stringer, then encoding.TextMarshaler. If neither applies, scalar values use the same formatting as flattening, structs use `%+v`, arrays and slices stringify each item recursively, maps stringify each key and value recursively, pointers use `<pointer> -> <converted pointed value>`, and everything else falls back to fmt.Sprint. Errors returned by encoding.TextMarshaler.MarshalText are propagated to the caller.

type ValueConverterFunc

type ValueConverterFunc func(ctx context.Context, value any) (any, error)

ValueConverterFunc adapts a function into IValueConverter.

A nil function behaves like IdentityConverter: it returns the input value unchanged and reports no error.

func (ValueConverterFunc) ConvertValue

func (f ValueConverterFunc) ConvertValue(ctx context.Context, value any) (any, error)

ConvertValue applies f to value.

Jump to

Keyboard shortcuts

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