Documentation ¶
Index ¶
- Constants
- Variables
- func CheckEvtArgs(args []interface{}) error
- func CloneMap(src map[string]interface{}) (dst map[string]interface{})
- func CopyMap(src, dst map[string]interface{})
- func DecodeMap(srcMap interface{}, dest interface{}, tagName ...string) error
- func DecodeMapStrict(srcMap interface{}, dest interface{}, tagName ...string) error
- func DecodeNumber(encNum []byte) uint64
- func DecodeWithJSON(src interface{}, dest interface{}) error
- func EncodeNumber(n uint64) []byte
- func FatalOnError(err error)
- func FromHex(hexValue string) ([]byte, error)
- func FromHexBytes(src []byte) []byte
- func GetPtrAddr(ptrAddr interface{}) *big.Int
- func HexToInt64(hexVal string) (int64, error)
- func HexToStr(hexStr string) (string, error)
- func Int64ToHex(intVal int64) string
- func IsBoolChanClosed(c chan bool) bool
- func IsEmojiValid(short string) bool
- func IsFileOk(path string) bool
- func IsFuncChanClosed(c <-chan func()) bool
- func IsGitInstalled(path string) (bool, string)
- func IsMapOrStruct(o interface{}) bool
- func IsPathOk(path string) bool
- func IsString(v interface{}) bool
- func IsStructChanClosed(c <-chan struct{}) bool
- func IsZeroString(str string) bool
- func MayDecodeNumber(encNum []byte) (r uint64, err error)
- func MustFromHex(hexValue string) []byte
- func MustToJSON(obj interface{}) string
- func NonZeroOrDefIn64(v int64, def int64) int64
- func NonZeroOrDefString(v string, def string) string
- func Notify(val ...interface{})
- func ParseContentFrontMatter(rdr io.Reader) (pageparser.ContentFrontMatter, error)
- func ParseExtArgs(extArgs map[string]string) (extsArgs map[string]map[string]string, common map[string]string)
- func ParseGitVersion(version string) (ver string)
- func ParseLogLevel(val string) (res map[string]logrus.Level)
- func ParseVerbs(tmp string, verbsValue map[string]interface{}) string
- func PtrStrToFloat(inp *string) float64
- func PtrStrToFloatE(inp *string) (float64, error)
- func PtrStrToUInt64(inp *string) uint64
- func RESTApiErrorMsg(msg, field string, code string) map[string]interface{}
- func RandBytes(n int) []byte
- func RandString(n int) string
- func ReadFromEditor(editor string, stdIn io.Reader, stdOut, stdErr io.Writer) (string, error)
- func RemoveFlag(args []string, flags ...string) []string
- func RemoveFromStringSlice(slice []string, str string) []string
- func SplitNamespaceDomain(name string) (ns string, domain string, err error)
- func StrToDec(val string) decimal.Decimal
- func StrToHex(str string) string
- func ToByteSlice(v []int) []byte
- func ToBytes(s interface{}) []byte
- func ToHex(value []byte, noPrefix ...bool) string
- func ToHexBytes(src []byte) []byte
- func ToJSONMap(s interface{}) (m map[string]interface{})
- func ToMap(s interface{}, tagName ...string) map[string]interface{}
- func ToObject(bs []byte, dest interface{}) error
- func ToStringMapInter(m interface{}, structToMap ...bool) map[string]interface{}
- func VMSet(vm *otto.Otto, name string, value interface{}) interface{}
- func WriteJSON(w http.ResponseWriter, statuscode int, respObj interface{})
- func XorBytes(a, b []byte) []byte
- type BlockNonce
- type Bytes
- type Bytes32
- func (b Bytes32) Big() *big.Int
- func (b Bytes32) Bytes() []byte
- func (b Bytes32) Equal(o Bytes32) bool
- func (b Bytes32) Hex() []byte
- func (b Bytes32) HexStr() string
- func (b Bytes32) IsEmpty() bool
- func (b Bytes32) MarshalJSON() ([]byte, error)
- func (b Bytes32) String() string
- func (b Bytes32) ToHexBytes() HexBytes
- type Bytes64
- type Cmd
- type CodecUtil
- type CommandCreator
- type Decoder
- type EditorReaderFunc
- type Encoder
- type HexBytes
- type Int64
- type Interrupt
- type Map
- type String
- func (s String) Address() identifier.Address
- func (s String) Bytes() []byte
- func (s String) Decimal() decimal.Decimal
- func (s String) Empty() bool
- func (s String) Equal(o String) bool
- func (s String) Float() float64
- func (s String) FloatE() (float64, error)
- func (s String) IsDecimal() bool
- func (s String) IsNumeric() bool
- func (s String) IsZero() bool
- func (s String) SS() string
- func (s String) String() string
- func (s String) UInt64() uint64
- type TMAddress
- type UInt64
- type WrappedCmd
- func (w *WrappedCmd) CombinedOutput() ([]byte, error)
- func (w *WrappedCmd) Output() ([]byte, error)
- func (w *WrappedCmd) ProcessWait() error
- func (w *WrappedCmd) Run() error
- func (w *WrappedCmd) SetStderr(writer io.Writer)
- func (w *WrappedCmd) SetStdin(rdr io.Reader)
- func (w *WrappedCmd) SetStdout(writer io.Writer)
- func (w *WrappedCmd) Start() error
- func (w *WrappedCmd) StderrPipe() (io.ReadCloser, error)
- func (w *WrappedCmd) StdinPipe() (io.WriteCloser, error)
- func (w *WrappedCmd) StdoutPipe() (io.ReadCloser, error)
- func (w *WrappedCmd) Wait() error
Constants ¶
const ( Length32 = 32 Length64 = 64 )
Constants
Variables ¶
var Big0 = new(big.Int).SetInt64(0)
Big0 represents a zero value big.Int
var EmojiCodeMap = map[string]string{}/* 4670 elements not displayed */
Mapping from character to concrete escape code.
var EmptyBytes32 = Bytes32([Length32]byte{})
EmptyBytes32 is an empty Bytes32
var EmptyBytes64 = Bytes64([Length64]byte{})
EmptyBytes64 is an empty Bytes64
Functions ¶
func CheckEvtArgs ¶
func CheckEvtArgs(args []interface{}) error
CheckEvtArgs checks whether the arguments of an event conforms to the expected standard where only 2 arguments are expected; Argument 0: WaitForResult Argument 1: Error Panics if standard is not met
func DecodeMap ¶
DecodeMap decodes a map to a struct with weak conversion. Default tagname is 'json'
func DecodeMapStrict ¶
DecodeMapStrict decodes a map to a struct with strict type check. Default tagname is 'json'
func DecodeNumber ¶
DecodeNumber deserialize a number from BigEndian
func DecodeWithJSON ¶
func DecodeWithJSON(src interface{}, dest interface{}) error
DecodeWithJSON is like DecodeMap but it marshals src and Unmarshal to dest using encode/json.
func EncodeNumber ¶
EncodeNumber serializes a number to BigEndian
func FatalOnError ¶
func FatalOnError(err error)
FatalOnError logs a message of Fatal level if err is not nil
func FromHex ¶
FromHex decodes hex value to bytes. If hex value is prefixed with '0x' it is trimmed before the decode operation.
func GetPtrAddr ¶
GetPtrAddr takes a pointer and returns the address
func HexToInt64 ¶
HexToInt64 attempts to convert an hex string to Int64. Expects the hex string to begin with '0x'.
func Int64ToHex ¶
Int64ToHex converts an Int64 value to hex string. The resulting hex is prefixed by '0x'
func IsBoolChanClosed ¶
IsBoolChanClosed checks whether a boolean channel is closed
func IsEmojiValid ¶
IsEmojiValid checks whether a given emoji is valid
func IsFuncChanClosed ¶
func IsFuncChanClosed(c <-chan func()) bool
IsFuncChanClosed checks whether a function channel is closed
func IsGitInstalled ¶
IsGitInstalled checks whether git executable exist in the given path. Returns true and git version if installed or false.
func IsMapOrStruct ¶
func IsMapOrStruct(o interface{}) bool
IsMapOrStruct checks whether o is a map or a struct (pointer to struct)
func IsStructChanClosed ¶
func IsStructChanClosed(c <-chan struct{}) bool
IsStructChanClosed checks whether a struct channel is closed
func IsZeroString ¶
IsZeroString returns true if str is empty or equal "0"
func MayDecodeNumber ¶
MayDecodeNumber is like DecodeNumber but returns an error instead of panicking
func MustFromHex ¶
MustFromHex is like FromHex except it panics if an error occurs
func MustToJSON ¶
func MustToJSON(obj interface{}) string
MustToJSON converts the give obj to valid JSON. Panics if unsuccessful.
func NonZeroOrDefIn64 ¶
NonZeroOrDefIn64 returns v if non-zero, otherwise it returns def
func NonZeroOrDefString ¶
NonZeroOrDefString returns v if non-zero, otherwise it returns def
func ParseContentFrontMatter ¶
func ParseContentFrontMatter(rdr io.Reader) (pageparser.ContentFrontMatter, error)
ParseFrontMatterContent parses a reader containing front matter + content.
func ParseExtArgs ¶
func ParseExtArgs(extArgs map[string]string) (extsArgs map[string]map[string]string, common map[string]string)
ParseExtArgs parses an extension arguments map. It takes a map of the form: 'extName.arg = value' and returns 'extName={arg=value...arg2=value2}'
func ParseGitVersion ¶
ParseGitVersion extracts semver version from `git version` output
func ParseLogLevel ¶
ParseLogLevel parse value from --loglevel flag
func ParseVerbs ¶
ParseVerbs parses a template containing verbs prefixed with %.
func PtrStrToFloat ¶ added in v0.0.30
PtrStrToFloat cast string pointer to float64
func PtrStrToFloatE ¶ added in v0.0.30
PtrStrToFloatE is like PtrStrToFloat but returns error
func PtrStrToUInt64 ¶ added in v0.0.30
PtrStrToUInt64 cast string pointer to uint64
func RESTApiErrorMsg ¶
RESTApiErrorMsg returns a message suitable for reporting REST API errors
func ReadFromEditor ¶
ReadFromEditor reads input from the specified editor program
func RemoveFlag ¶
RemoveFlag takes a slice of arguments and remove specific flags
func RemoveFromStringSlice ¶
RemoveFromStringSlice removes str from the given string slice
func SplitNamespaceDomain ¶
SplitNamespaceDomain splits a full namespace address into namespace and domain
func StrToDec ¶
StrToDec converts a numeric string to decimal. Panics if val could not be converted to decimal.
func ToBytes ¶
func ToBytes(s interface{}) []byte
ToBytes returns msgpack encoded representation of s.
func ToJSONMap ¶
func ToJSONMap(s interface{}) (m map[string]interface{})
ToJSONMap converts s to json and then back to map. Panics if json encoding operation fails.
func ToMap ¶
ToMap converts a struct to a map. If tagName is not provided, 'json' tag is used as a default.
func ToStringMapInter ¶
ToStringMapInter converts a map to map[string]interface{}. If structToMap is true, struct element is converted to map. Panics if m is not a map with string key. Returns m if m is already a map[string]interface{}.
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, statuscode int, respObj interface{})
WriteJSON encodes respObj to json and writes it to w
Types ¶
type BlockNonce ¶
type BlockNonce [8]byte
BlockNonce represents a 64-bit
func EncodeNonce ¶
func EncodeNonce(i uint64) BlockNonce
EncodeNonce converts the given integer to a block nonce.
func (BlockNonce) MarshalJSON ¶
func (n BlockNonce) MarshalJSON() ([]byte, error)
func (BlockNonce) Uint64 ¶
func (n BlockNonce) Uint64() uint64
Uint64 returns the integer value of a block nonce.
type Bytes ¶
type Bytes []byte
Bytes represents a byte slice
func (Bytes) MarshalJSON ¶
type Bytes32 ¶
Bytes32 represents a 32-bytes value
func HexToBytes32 ¶
HexToBytes32 creates an hex value to Bytes32
func (Bytes32) MarshalJSON ¶
type Bytes64 ¶
Bytes64 represents a 32-bytes value
func (Bytes64) MarshalJSON ¶
type Cmd ¶
type Cmd interface { Run() error Start() error Wait() error Output() ([]byte, error) CombinedOutput() ([]byte, error) StdinPipe() (io.WriteCloser, error) StdoutPipe() (io.ReadCloser, error) StderrPipe() (io.ReadCloser, error) SetStderr(writer io.Writer) SetStdout(writer io.Writer) SetStdin(rdr io.Reader) ProcessWait() error }
Cmd provides an interface for exec.Cmd
func NewCommand ¶
NewCommand creates a Cmd instance
type CodecUtil ¶
type CodecUtil struct { // Version is the host object version. When the host object is encoded, this // version is added to the encoding before any other data fields. Version string // DecodeVersion is the version of the encoded data. DecodedVersion string // contains filtered or unexported fields }
CodecUtil provides convenient methods to serialize and deserialize objects. It is expected to be embedded in a struct to provided code utilities.
func (*CodecUtil) DecodeMulti ¶
DecodeMulti wraps msgpack.Decoder#DecodeMulti. It skips over version information. It ignores EOF errors.
func (*CodecUtil) DecodeVersion ¶
DecodeVersion decodes and returns the encoding's version
func (*CodecUtil) EncodeMulti ¶
EncodeMulti is a wraps msgpack.Encoder#EncodeMulti; It normalizes fields and performs pre-serialization operations
func (*CodecUtil) ResetCodec ¶
func (h *CodecUtil) ResetCodec()
type CommandCreator ¶
CommandCreator describes a function for creating a util.Cmd instance
type EditorReaderFunc ¶
type EditorReaderFunc func(editor string, stdIn io.Reader, stdOut, stdErr io.Writer) (string, error)
EditorReaderFunc describes a function that reads input from an editor program
type HexBytes ¶
type HexBytes []byte
HexBytes represents a slice of bytes
func StrToHexBytes ¶
StrToHexBytes converts a string to a HexBytes
func (HexBytes) MarshalJSON ¶
type Int64 ¶
type Int64 int64
Int64 wraps int64
func (Int64) MarshalJSON ¶
MarshalJSON marshals for JSON
func (*Int64) UnmarshalJSON ¶
type Interrupt ¶
type Interrupt chan struct{}
Interrupt is used to signal program interruption
func (*Interrupt) Close ¶
func (i *Interrupt) Close()
Close closes the channel only when it is not closed
type Map ¶
type Map map[string]interface{}
func StructSliceToMap ¶
StructSliceToMap converts struct slice s to a map slice. If tagName is not provided, 'json' tag is used as a default.
type String ¶
type String string
String represents a custom string
func (String) Address ¶
func (s String) Address() identifier.Address
Address converts the String to an Address
func (String) Decimal ¶
Decimal returns the decimal representation of the numeric string. If s is empty, '0' is assumed. Panics if string failed to be converted to decimal.
func (String) Float ¶
Float returns the float equivalent of the numeric value. Panics if not convertible to float64
func (String) FloatE ¶ added in v0.0.30
FloatE is like Float but returns error if unable to cast s to float64.
type TMAddress ¶
type TMAddress []byte
TMAddress represents a tendermint address
func (TMAddress) MarshalJSON ¶
func (*TMAddress) UnmarshalJSON ¶
type UInt64 ¶
type UInt64 uint64
UInt64 wraps uint64
func (UInt64) MarshalJSON ¶
MarshalJSON marshals for JSON
func (*UInt64) UnmarshalJSON ¶
type WrappedCmd ¶
type WrappedCmd struct {
// contains filtered or unexported fields
}
WrappedCmd implements Cmd which exec.Cmd conforms to.
func NewWrappedCmd ¶
func NewWrappedCmd(cmd *exec.Cmd) *WrappedCmd
NewWrappedCmd creates an instance of WrappedCmd
func (*WrappedCmd) CombinedOutput ¶
func (w *WrappedCmd) CombinedOutput() ([]byte, error)
WrappedCmd implements Cmd
func (*WrappedCmd) ProcessWait ¶
func (w *WrappedCmd) ProcessWait() error
func (*WrappedCmd) SetStderr ¶
func (w *WrappedCmd) SetStderr(writer io.Writer)
func (*WrappedCmd) SetStdin ¶
func (w *WrappedCmd) SetStdin(rdr io.Reader)
func (*WrappedCmd) SetStdout ¶
func (w *WrappedCmd) SetStdout(writer io.Writer)
func (*WrappedCmd) StderrPipe ¶
func (w *WrappedCmd) StderrPipe() (io.ReadCloser, error)
WrappedCmd implements Cmd
func (*WrappedCmd) StdinPipe ¶
func (w *WrappedCmd) StdinPipe() (io.WriteCloser, error)
WrappedCmd implements Cmd
func (*WrappedCmd) StdoutPipe ¶
func (w *WrappedCmd) StdoutPipe() (io.ReadCloser, error)
WrappedCmd implements Cmd