util

package
v1.0.99 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 2 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmptyValue

func IsEmptyValue(v interface{}) bool

IsEmptyValue checks whether v is considered empty using reflect. Returns true for nil interface, and zero values of the underlying type (e.g. "", 0, false, empty slice/map).

func IsNil

func IsNil(v interface{}) bool

IsNil reports whether v is nil, covering both untyped nil (interface itself) and typed nil (e.g. (*T)(nil) wrapped in interface{}). Avoids direct interface{} == nil comparison .

func ToFloat64

func ToFloat64(v interface{}) (float64, bool)

ToFloat64 extracts a float64 from a value that may be float64 or json.Number. Returns (0, false) if the value is neither.

func TruncateStr

func TruncateStr(s string, n int) string

TruncateStr truncates s to at most n runes, safe for multi-byte (e.g. CJK) characters.

func TruncateStrWithEllipsis

func TruncateStrWithEllipsis(s string, n int) string

TruncateStrWithEllipsis truncates s to at most n runes (including "..." suffix).

Types

This section is empty.

Jump to

Keyboard shortcuts

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