common

package
v0.0.0-...-8aa4d74 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEncodes = map[string]Encode{
	"json": func(v interface{}, w io.Writer) error {
		return jsonEncode(v, w, false)
	},
	"prettyjson": func(v interface{}, w io.Writer) error {
		return jsonEncode(v, w, true)
	},
	"yaml": func(v interface{}, w io.Writer) error {
		e := yaml.NewEncoder(w)
		return e.Encode(v)
	},
}

Functions

func GetDefaultStoragePath

func GetDefaultStoragePath(cmd *cobra.Command) string

Get the default value to assign to the `--storage` flag

func Interrupt

func Interrupt(cancel <-chan struct{}) error

func ParseAmountFromString

func ParseAmountFromString(input string) (common.Amount, error)

Parse an input string as a monetary amount

Commas (','), and dots ('.') and underscores ('_') are treated as digit separator, and not decimal separators, and will be skipped.

Params:

input = the string representation of the amount, in GON

Returns:

sebak.Amount: the value represented by `input`
error: an `error`, if any happened

func PrintError

func PrintError(cmd *cobra.Command, err error)

func PrintFlagsError

func PrintFlagsError(cmd *cobra.Command, flagName string, err error)

*

  • Issue a message on Stderr then exit with an error code

Types

type Encode

type Encode func(v interface{}, w io.Writer) error

type ListFlags

type ListFlags []string

func (*ListFlags) Set

func (i *ListFlags) Set(value string) error

func (*ListFlags) String

func (i *ListFlags) String() string

func (*ListFlags) Type

func (i *ListFlags) Type() string

Jump to

Keyboard shortcuts

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