conv

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 3 Imported by: 16

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 added in v0.1.6

func Bool(val any) bool

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

func Bools added in v0.1.8

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

Bools returns the boolean slice representation of the values.

func ByteSizes added in v0.1.7

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 added in v0.1.8

func Bytes(val any) []byte

Bytes returns the byte slice representation of the value.

func Int added in v0.1.8

func Int(val any) int

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

func Ints added in v0.1.8

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 added in v0.1.8

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

Strings returns the string slice representation of the values.

Types

type ByteSize added in v0.1.7

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