convbytes

package
v6.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  int64 = 1
	KB       = B * 1024
	MB       = KB * 1024
	GB       = MB * 1024
	TB       = GB * 1024
	PB       = TB * 1024
)

Variables

This section is empty.

Functions

func Convert

func Convert(value int64, fromUnit int64, toUnit int64) int64

Convert converts a value from a source unit to a target unit.

func FromBytes

func FromBytes(bytes int64, unit int64) int64

FromBytes converts a given byte value to a target unit.

func StrToBytes

func StrToBytes(s string) int64

func StrToBytesOk

func StrToBytesOk(s string) (int64, bool)

StrToBytesOk converts your bytes string to bytes, for use with other convbytes pkg funcs

func StrToUnit

func StrToUnit(s string, targetUnit int64) int64

StrToUnit converts a size string to a target unit and returns the converted value.

func StrToUnitOk

func StrToUnitOk(s string, targetUnit int64) (int64, bool)

StrToUnitOk converts a size string to a target unit and returns the converted value and a boolean indicating if the conversion was successful.

func ToBytes

func ToBytes(value int64, unit int64) int64

ToBytes converts a given value in a source unit to bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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