datarate

package module
v0.0.0-...-31ca770 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 5 Imported by: 1

README

datarate

The datarate package parses strings like "10 KB/s" into a usable type in golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datarate

type Datarate struct {
	unit.Datarate
}

Datarate wraps a github.com/martinlindhe/unit.Datarate and extends it with new functionality. It is now parsable from strings and yaml

func Parse

func Parse(s string) (*Datarate, error)

Parse reads a string in the format "<number><unit>/<duration>" and produces a Datarate object. Since data rates are usually metric (base 10), we only support those. eg. megabit/s, not mebibit/s Example: datarate.Parse("10KB/s") // 10 kilobyte per second Bad Example: data.Parse("10KiB/s") // error: kibibytes not supported

func (*Datarate) UnmarshalYAML

func (dr *Datarate) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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