bytecount

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 5

README

A datatype to hold counts of bytes.

Useful for setting byte counts as command-line arguments

Documentation

Overview

Package bytecount provides a single datatype ByteCount, designed to track counts of bytes, as well as some helper constants. It also provides all the necessary functions to allow a ByteCount to be specified as a command-line argument, which should allow command-line arguments like `--cache-size=20MB`.

Index

Constants

View Source
const (
	Byte     ByteCount = 1
	Kilobyte           = 1000 * Byte
	Megabyte           = 1000 * Kilobyte
	Gigabyte           = 1000 * Megabyte
)

Some constants to make working with ByteCounts easier. If the difference between Kilobytes and Kibibytes matters to you, then this package is likely too unsophisticated for your needs. Pull requests are welcome, however.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteCount

type ByteCount int64

ByteCount holds filesizes and the like.

func (ByteCount) Get

func (b ByteCount) Get() interface{}

Get is used by the Flag package to get the value out of the ByteCount.

func (*ByteCount) Set

func (b *ByteCount) Set(s string) error

Set is used by the Flag package to turn a string into a ByteCount. This implementation parses on the quick and dirty using regular expressions.

func (ByteCount) String

func (b ByteCount) String() string

String is used by the Flag package to turn the value into a string. Because we output bytecounts in our logs, it is worth it to convert them into readable values.

Jump to

Keyboard shortcuts

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