sizespec

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: MIT Imports: 2 Imported by: 10

Documentation

Overview

Package sizespec implements a parser for size specifications. Yep, we could use regexes, but then we don't get to tell people where they failed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(spec string) (size int, err error)

Parse will take a size as a string like <num>[G|M][[i]B] and output an int - the size in megabytes. It's actually more permissive than that but w/e

Types

type Error

type Error struct {
	// Position is the index in Spec at which the the unexpected character was found.
	Position int
	// Character is the character that was unexpected.
	Character rune
	// Spec is the full size spec that caused the error.
	Spec string
}

Error indicates that the size spec could not be parsed.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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