sizes

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Copyright (c) 2025 EterLine (Andrew) This file is part of fstmon. Licensed under the MIT License. See the LICENSE file for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SizeBitBase

type SizeBitBase uint64
const (
	Bit SizeBitBase = 1 << (10 * iota) // 1, 1024, 1024^2, ...
	Kb
	Mb
	Gb
	Tb
	Pb
	Eb
)

Bit-based sizes

func DetermBitBase added in v1.5.9

func DetermBitBase(bitsSize uint64) (float64, SizeBitBase)

func DetermByte2BitBase

func DetermByte2BitBase(bytesSize uint64) (float64, SizeBitBase)

func (SizeBitBase) String

func (d SizeBitBase) String() string

type SizeByteBase

type SizeByteBase uint64
const (
	Byte SizeByteBase = 1 << (10 * iota) // 1, 1024, 1024^2, ...
	KB                                   // Kilobyte
	MB                                   // Megabyte
	GB                                   // Gigabyte
	TB                                   // Terabyte
	PB                                   // Petabyte
	EB                                   // Exabyte
)

Byte-based sizes

func DetermByte2ByteBase

func DetermByte2ByteBase(bytesSize uint64) (float64, SizeByteBase)

func (SizeByteBase) In added in v1.5.9

func (d SizeByteBase) In(v uint64) uint64

func (SizeByteBase) String

func (d SizeByteBase) String() string

type SizeISOMetric

type SizeISOMetric uint64

SizeISOMetric — 1000-based SI units (Extended)

const (
	ZERO SizeISOMetric = 0

	K SizeISOMetric = 1_000
	M SizeISOMetric = 1_000_000             // 1000^2
	G SizeISOMetric = 1_000_000_000         // 1000^3
	T SizeISOMetric = 1_000_000_000_000     // 1000^4
	P SizeISOMetric = 1_000_000_000_000_000 // 1000^5
	E SizeISOMetric = 1_000_000_000_000_000_000
)

1000^n units starting from K (10^3) up to Y (10^24)

func DetermMetricBase

func DetermMetricBase(size uint64) (float64, SizeISOMetric)

DetermMetricBase — chooses the best SI unit (K..Y) for the given value. Returns normalized value + the matched SI unit.

func (SizeISOMetric) String

func (u SizeISOMetric) String() string

Jump to

Keyboard shortcuts

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