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 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址