bits2str

package module
v0.0.0-...-75e0f8a Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: MIT Imports: 0 Imported by: 2

README

bits2str

Golang bits to string converter

Install

go get -u github.com/moisespsena-go/bits2str/...  

Usage

package main

import github.com/moisespsena-go/bits2str

func main() {
  println(bits2str.Bits(1024).String())
}

CLI

bits2str 1024

or...

echo '1024
4
4200' | bits2str

Documentation

Index

Constants

View Source
const (
	Bit  Bits = 1
	Byte      = 8 * Bit
	// https://en.wikipedia.org/wiki/Orders_of_magnitude_(data)
	KB = 1000 * Byte
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB
	EB = 1000 * PB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bits

type Bits int64

Bits represents a quantity of Bits, bytes, kilobytes or megabytes. Bits are parsed and formatted using the IEEE / SI standards, which use multiples of 1000 to represent kilobytes and megabytes (instead of multiples of 1024). For more information see https://en.wikipedia.org/wiki/Megabyte#Definitions.

func (Bits) Bytes

func (b Bits) Bytes() float64

Bytes returns the size as a floating point number of bytes.

func (Bits) Gigabytes

func (b Bits) Gigabytes() float64

Gigabytes returns the size as a floating point number of gigabytes.

func (Bits) Kilobytes

func (b Bits) Kilobytes() float64

Kilobytes returns the size as a floating point number of kilobytes.

func (Bits) Megabytes

func (b Bits) Megabytes() float64

Megabytes returns the size as a floating point number of megabytes.

func (Bits) String

func (b Bits) String() string

String returns a string representation of b using the largest unit that has a positive number before the decimal. At most three decimal places of precision are printed.

Jump to

Keyboard shortcuts

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