formatting

package
v1.4.9-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: BSD-3-Clause Imports: 9 Imported by: 141

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode added in v1.0.6

func Decode(encoding Encoding, str string) ([]byte, error)

Decode [str] to bytes using the given encoding If [str] is the empty string, returns a nil byte slice and nil error

func Encode added in v1.0.6

func Encode(encoding Encoding, bytes []byte) (string, error)

Encode bytes to a string using the given encoding format bytes may be nil, in which case it will be treated the same as an empty slice

func FormatAddress added in v0.8.0

func FormatAddress(
	chainIDAlias string,
	hrp string,
	addr []byte,
) (string, error)

FormatAddress takes in a chain prefix, HRP, and byte slice to produce a string for an address.

func FormatBech32 added in v0.8.0

func FormatBech32(hrp string, payload []byte) (string, error)

FormatBech32 takes an address's bytes as input and returns a bech32 address

func IntFormat

func IntFormat(maxValue int) string

IntFormat ...

func ParseAddress added in v0.8.0

func ParseAddress(addrStr string) (string, string, []byte, error)

ParseAddress takes in an address string and splits returns the corresponding parts. This returns the chain ID alias, bech32 HRP, address bytes, and an error if it occurs.

func ParseBech32 added in v0.8.0

func ParseBech32(addrStr string) (string, []byte, error)

ParseBech32 takes a bech32 address as input and returns the HRP and data section of a bech32 address

Types

type CustomStringer

type CustomStringer struct{ Stringer func() string }

CustomStringer ...

func (CustomStringer) String

func (cs CustomStringer) String() string

type DumpBytes

type DumpBytes struct{ Bytes []byte }

DumpBytes ...

func (DumpBytes) String

func (db DumpBytes) String() string

type Encoding added in v1.0.3

type Encoding uint8

Encoding defines how bytes are converted to a string and vice versa

const (
	// CB58 specifies the CB58 encoding format
	CB58 Encoding = iota
	// Hex specifies a hex plus 4 byte checksum encoding format
	Hex
)

func (Encoding) MarshalJSON added in v1.0.6

func (enc Encoding) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Encoding) String added in v1.0.6

func (enc Encoding) String() string

String ...

func (*Encoding) UnmarshalJSON added in v1.0.6

func (enc *Encoding) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type PrefixedStringer

type PrefixedStringer interface {
	fmt.Stringer

	PrefixedString(prefix string) string
}

PrefixedStringer extends a stringer that adds a prefix

Jump to

Keyboard shortcuts

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