conv

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 3 Imported by: 14

Documentation

Overview

Packag conv provides functions for converting between different types.

Index

Constants

This section is empty.

Variables

View Source
var ByteSizeUnits = map[string]ByteSize{
	"B":  B,
	"KB": KB,
	"MB": MB,
	"GB": GB,
	"TB": TB,
	"PB": PB,
	"EB": EB,
}

ByteSizeUnits is a map of byte sizes.

Functions

func Bool

func Bool(val any) bool

Bool returns the boolean representation of the value. nolint:gocyclo

func Bools

func Bools[T any](vals ...T) []bool

Bools returns the boolean slice representation of the values.

func ByteSizes

func ByteSizes(b float64, size string) int64

ByteSizes converts a value of float64 to a full integer value of a byte based on a unit size.

func Bytes

func Bytes(val any) []byte

Bytes returns the byte slice representation of the value.

func Int

func Int(val any) int

Int returns the integer representation of the value. nolint:gocyclo

func Ints

func Ints[T any](vals ...T) []int

Ints returns the integer slice representation of the values.

func String

func String(val any) string

String returns the string representation of the value.

func Strings

func Strings[T any](vals ...T) []string

Strings returns the string slice representation of the values.

Types

type ByteSize

type ByteSize int64

ByteSize represents the size of a value in bits.

const (
	B  ByteSize = 1
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
)

Jump to

Keyboard shortcuts

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