common

package
v0.0.0-...-0872f49 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2017 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const MSB = 0x80
View Source
const SEG = 1024

Variables

View Source
var (
	ErrInvalidCondition   = Error("Invalid condition")
	ErrInvalidFulfillment = Error("Invalid fulfillment")
	ErrInvalidId          = Error("Invalid id")
	ErrInvalidKey         = Error("Invalid key")
	ErrInvalidSignature   = Error("Invalid signature")
	ErrInvalidSize        = Error("Invalid size")
	ErrInvalidType        = Error("Invalid type")
)
View Source
var FPrintf = fmt.Fprintf
View Source
var FPrintln = fmt.Fprintln
View Source
var NewSha256 = sha3.New256
View Source
var Print = fmt.Print
View Source
var Printf = fmt.Printf
View Source
var Println = fmt.Println
View Source
var Sprintf = fmt.Sprintf
View Source
var Stdout = os.Stdout

Functions

func AssertInt

func AssertInt(v interface{}) int

func AssertStr

func AssertStr(v interface{}) string

func AssertStrSlice

func AssertStrSlice(v interface{}) []string

func Atoi

func Atoi(s string) (int, error)

func Base64StdDecode

func Base64StdDecode(b64 string) ([]byte, error)

func Base64StdEncode

func Base64StdEncode(p []byte) string

func Base64UrlDecode

func Base64UrlDecode(b64 string) ([]byte, error)

func Base64UrlEncode

func Base64UrlEncode(p []byte) string

Base64

func BigIntFromBytes

func BigIntFromBytes(p []byte) *big.Int

func BlockPEM

func BlockPEM(p []byte, _type string) *pem.Block

PEM

func BytesFloat32

func BytesFloat32(x float32) []byte

func BytesFloat32s

func BytesFloat32s(x []float32) []byte

func BytesFloat64

func BytesFloat64(x float64) []byte

func BytesFloat64s

func BytesFloat64s(x []float64) []byte

func BytesFromB58

func BytesFromB58(b58 string) []byte

func BytesFromHex

func BytesFromHex(hexstr string) ([]byte, error)

func BytesInt16

func BytesInt16(x int16) []byte

func BytesInt16s

func BytesInt16s(x []int16) []byte

func BytesInt32

func BytesInt32(x int32) []byte

func BytesInt32s

func BytesInt32s(x []int32) []byte

func BytesInt64

func BytesInt64(x int64) []byte

func BytesInt64s

func BytesInt64s(x []int64) []byte

func BytesToB58

func BytesToB58(p []byte) string

B58

func BytesToHex

func BytesToHex(p []byte) string

Hex

func Check

func Check(err error)

func Checksum256

func Checksum256(p []byte) []byte

func Copy

func Copy(w io.Writer, r io.Reader) error

func CopySize

func CopySize(w io.Writer, r io.Reader) (int64, error)

func CreateFile

func CreateFile(path string) (*os.File, error)

func DecodePEM

func DecodePEM(p []byte) (*pem.Block, []byte)

func DeepEqual

func DeepEqual(x, y interface{}) bool

func DumpCBOR

func DumpCBOR(v interface{}) ([]byte, error)

func EmptyStr

func EmptyStr(s string) bool

func EncodePEM

func EncodePEM(b *pem.Block) []byte

func Error

func Error(msg string) error

func ErrorAppend

func ErrorAppend(err error, msg string) error

func ErrorJoin

func ErrorJoin(err1, err2 error) error

func Errorf

func Errorf(format string, args ...interface{}) error

func EvenSquare

func EvenSquare(n int) bool

func Exp2

func Exp2(x int) int

func FillStruct

func FillStruct(s interface{}, data map[string]interface{}) (err error)

func Float32

func Float32(p []byte) (float32, error)

func Float32s

func Float32s(p []byte) ([]float32, error)

func Float64

func Float64(p []byte) (float64, error)

func Float64s

func Float64s(p []byte) ([]float64, error)

func FormatInt

func FormatInt(x int64, base int) string

func FormatInt64

func FormatInt64(x int64, base int) string

func GetMyIP

func GetMyIP() (string, error)

func Getenv

func Getenv(key string) string

func HttpGet

func HttpGet(url string) (*http.Response, error)

func HttpGetRequest

func HttpGetRequest(url string, body io.Reader, kv map[string]string) (*http.Response, error)

func HttpPost

func HttpPost(url, bodyType string, body io.Reader) (*http.Response, error)

func HttpPostRequest

func HttpPostRequest(url string, body io.Reader, kv map[string]string) (*http.Response, error)

func HttpRequest

func HttpRequest(method, url string, body io.Reader, kv map[string]string) (*http.Response, error)

func HttpsClient

func HttpsClient() *http.Client

func HttpsTransport

func HttpsTransport() *http.Transport

func Int16

func Int16(p []byte) (int16, error)

func Int16s

func Int16s(p []byte) ([]int16, error)

func Int32

func Int32(p []byte) (x int32, err error)

func Int32s

func Int32s(p []byte) ([]int32, error)

func Int64

func Int64(p []byte) (int64, error)

func Int64s

func Int64s(p []byte) ([]int64, error)

func Itoa

func Itoa(x int) string

func LoadCBOR

func LoadCBOR(p []byte, v interface{}) error

func Log2Ceil

func Log2Ceil(x int) int

func Log2Floor

func Log2Floor(x int) int

func MarshalIndentJSON

func MarshalIndentJSON(v interface{}) ([]byte, error)

func MarshalJSON

func MarshalJSON(v interface{}) ([]byte, error)

JSON

func Match

func Match(pattern string, p []byte) bool

func MatchStr

func MatchStr(pattern, s string) bool

func MatchUrlRelaxed

func MatchUrlRelaxed(rawurl string) bool

func MatchUrlStrict

func MatchUrlStrict(rawurl string) bool

func MustAtoi

func MustAtoi(s string) int

func MustBase64StdDecode

func MustBase64StdDecode(b64 string) []byte

func MustBase64UrlDecode

func MustBase64UrlDecode(b64 string) []byte

func MustBytesFromHex

func MustBytesFromHex(hexstr string) []byte

func MustCopy

func MustCopy(w io.Writer, r io.Reader)

func MustCreateFile

func MustCreateFile(path string) *os.File

func MustDumpCBOR

func MustDumpCBOR(v interface{}) []byte

func MustLoadCBOR

func MustLoadCBOR(p []byte, v interface{})

func MustMarshalIndentJSON

func MustMarshalIndentJSON(v interface{}) []byte

func MustMarshalJSON

func MustMarshalJSON(v interface{}) []byte

func MustOpenFile

func MustOpenFile(path string) *os.File

func MustOpenWriteFile

func MustOpenWriteFile(path string) *os.File

func MustParseInt64

func MustParseInt64(s string, base int) int64

func MustParseQuery

func MustParseQuery(query string) url.Values

func MustParseUint16

func MustParseUint16(s string, base int) int

func MustParseUint32

func MustParseUint32(s string, base int) int

func MustParseUint64

func MustParseUint64(s string, base int) int

func MustParseUrl

func MustParseUrl(rawurl string) *url.URL

func MustPeek

func MustPeek(r io.Reader) byte

func MustReadAll

func MustReadAll(r io.Reader) []byte

func MustReadFile

func MustReadFile(path string) []byte

func MustReadFull

func MustReadFull(r io.Reader, buf []byte)

func MustReadJSON

func MustReadJSON(r io.Reader, v interface{})

func MustReadN

func MustReadN(r io.Reader, n int) []byte

func MustReadSeeker

func MustReadSeeker(r io.Reader) io.ReadSeeker

func MustReadUint16

func MustReadUint16(r io.Reader) int

func MustReadUint32

func MustReadUint32(r io.Reader) int

func MustReadUint64

func MustReadUint64(r io.Reader) int

func MustReadVarOctet

func MustReadVarOctet(r io.Reader) []byte

func MustReadVarUint

func MustReadVarUint(r io.Reader) int

func MustSetenv

func MustSetenv(key, value string)

func MustTeeSeeker

func MustTeeSeeker(r io.Reader) (io.ReadSeeker, io.Reader)

func MustUint16

func MustUint16(p []byte) int

func MustUint32

func MustUint32(p []byte) int

func MustUint64

func MustUint64(p []byte) int

func MustUnmarshalJSON

func MustUnmarshalJSON(p []byte, v interface{})

func MustVarOctetBytes

func MustVarOctetBytes(octet []byte) []byte

func MustVarUint

func MustVarUint(octet []byte) int

func MustWrite

func MustWrite(p []byte, w io.Writer)

func MustWriteJSON

func MustWriteJSON(w io.Writer, v interface{})

func Now

func Now() time.Time

func OpenFile

func OpenFile(path string) (*os.File, error)

func OpenWriteFile

func OpenWriteFile(path string) (*os.File, error)

func Panicf

func Panicf(format string, args ...interface{})

func ParseBool

func ParseBool(s string) (bool, error)

func ParseDate

func ParseDate(date string) (time.Time, error)

func ParseInt32

func ParseInt32(s string, base int) (int32, error)

func ParseInt64

func ParseInt64(s string, base int) (int64, error)

func ParseQuery

func ParseQuery(query string) (url.Values, error)

func ParseUint16

func ParseUint16(s string, base int) (int, error)

func ParseUint32

func ParseUint32(s string, base int) (int, error)

func ParseUint64

func ParseUint64(s string, base int) (int, error)

func ParseUrl

func ParseUrl(rawurl string) (*url.URL, error)

func Peek

func Peek(r io.Reader) (byte, error)

func Pipe

func Pipe() (r io.Reader, w io.Writer)

func Pow2

func Pow2(x int) bool

func Pow2Ceil

func Pow2Ceil(x int) int

func Pow2Floor

func Pow2Floor(x int) int

func PrintJSON

func PrintJSON(v interface{})

func PrintNewlines

func PrintNewlines(n int)

func ReadAll

func ReadAll(r io.Reader) ([]byte, error)

func ReadFile

func ReadFile(path string) ([]byte, error)

func ReadFloat32

func ReadFloat32(r io.Reader) (x float32, err error)

func ReadFloat32s

func ReadFloat32s(r io.Reader, seg int) (x []float32, err error)

func ReadFloat64

func ReadFloat64(r io.Reader) (x float64, err error)

func ReadFloat64s

func ReadFloat64s(r io.Reader, seg int) (x []float64, err error)

func ReadFull

func ReadFull(r io.Reader, buf []byte) error

func ReadInt16

func ReadInt16(r io.Reader) (x int16, err error)

func ReadInt16s

func ReadInt16s(r io.Reader, seg int) (x []int16, err error)

func ReadInt32

func ReadInt32(r io.Reader) (x int32, err error)

func ReadInt32s

func ReadInt32s(r io.Reader, seg int) (x []int32, err error)

func ReadInt64

func ReadInt64(r io.Reader) (x int64, err error)

func ReadInt64s

func ReadInt64s(r io.Reader, seg int) (x []int64, err error)

func ReadJSON

func ReadJSON(r io.Reader, v interface{}) error

func ReadN

func ReadN(r io.Reader, n int) ([]byte, error)

func ReadNFloat32s

func ReadNFloat32s(r io.Reader, n int) ([]float32, error)

func ReadNFloat64s

func ReadNFloat64s(r io.Reader, n int) ([]float64, error)

func ReadNInt16s

func ReadNInt16s(r io.Reader, n int) ([]int16, error)

func ReadNInt32s

func ReadNInt32s(r io.Reader, n int) ([]int32, error)

func ReadNInt64s

func ReadNInt64s(r io.Reader, n int) ([]int64, error)

func ReadSeeker

func ReadSeeker(r io.Reader) (io.ReadSeeker, error)

func ReadUint16

func ReadUint16(r io.Reader) (int, error)

func ReadUint32

func ReadUint32(r io.Reader) (int, error)

func ReadUint64

func ReadUint64(r io.Reader) (int, error)

func ReadVarOctet

func ReadVarOctet(r io.Reader) (octet []byte, err error)

func ReadVarUint

func ReadVarUint(r io.Reader) (int, error)

func RepeatStr

func RepeatStr(s string, n int) string

func SetField

func SetField(s interface{}, name string, value interface{}) error

func Setenv

func Setenv(key, value string) error

func Shake256

func Shake256(p []byte, size int) []byte

func SleepMilli

func SleepMilli(d time.Duration)

func SleepSeconds

func SleepSeconds(d time.Duration)

func SplitStr

func SplitStr(s, sep string) []string

func StructToMap

func StructToMap(s interface{}) map[string]interface{}

func Submatch

func Submatch(pattern string, p []byte) [][]byte

func SubmatchStr

func SubmatchStr(pattern, s string) []string

func Tee

func Tee(r io.Reader, w io.Writer) io.Reader

func TeeSeeker

func TeeSeeker(r io.Reader) (io.ReadSeeker, io.Reader, error)

func Timestamp

func Timestamp() int64

func TimestampBytes

func TimestampBytes(x int64) []byte

func TimestampFromBytes

func TimestampFromBytes(p []byte) int64

func ToLower

func ToLower(s string) string

func Today

func Today() time.Time

func TypeOf

func TypeOf(i interface{}) string

func Uint16

func Uint16(p []byte) (int, error)

func Uint16Bytes

func Uint16Bytes(x int) []byte

func Uint32

func Uint32(p []byte) (int, error)

func Uint32Bytes

func Uint32Bytes(x int) []byte

func Uint64

func Uint64(p []byte) (int, error)

func Uint64Bytes

func Uint64Bytes(x int) []byte

func UnmarshalJSON

func UnmarshalJSON(p []byte, v interface{}) error

func VarOctet

func VarOctet(p []byte) (octet []byte)

func VarOctetBytes

func VarOctetBytes(octet []byte) ([]byte, error)

func VarOctetLength

func VarOctetLength(p []byte) int

func VarUint

func VarUint(octet []byte) (int, error)

func VarUintBytes

func VarUintBytes(x int) []byte

func VarUintSize

func VarUintSize(x int) int

func Write

func Write(p []byte, w io.Writer) error

func WriteFloat32

func WriteFloat32(w io.Writer, x float32) (err error)

func WriteFloat32s

func WriteFloat32s(w io.Writer, x []float32) (err error)

func WriteFloat64

func WriteFloat64(w io.Writer, x float64) (err error)

func WriteFloat64s

func WriteFloat64s(w io.Writer, x []float64) (err error)

func WriteInt16

func WriteInt16(w io.Writer, x int16) (err error)

func WriteInt16s

func WriteInt16s(w io.Writer, x []int16) (err error)

func WriteInt32

func WriteInt32(w io.Writer, x int32) (err error)

func WriteInt32s

func WriteInt32s(w io.Writer, x []int32) (err error)

func WriteInt64

func WriteInt64(w io.Writer, x int64) (err error)

func WriteInt64s

func WriteInt64s(w io.Writer, x []int64) (err error)

func WriteJSON

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

func WriteUint16

func WriteUint16(w io.Writer, x int)

func WriteUint32

func WriteUint32(w io.Writer, x int)

func WriteUint64

func WriteUint64(w io.Writer, x int)

func WriteVarOctet

func WriteVarOctet(w io.Writer, p []byte)

func WriteVarUint

func WriteVarUint(w io.Writer, x int)

Types

type Data

type Data map[string]interface{}

func AssertData

func AssertData(v interface{}) Data

func AssertDataSlice

func AssertDataSlice(v interface{}) []Data

func (Data) Clear

func (d Data) Clear(key string)

func (Data) Delete

func (d Data) Delete(key string)

func (Data) Get

func (d Data) Get(key string) interface{}

func (Data) GetData

func (d Data) GetData(key string) Data

func (Data) GetDataSlice

func (d Data) GetDataSlice(key string) []Data

func (Data) GetInt

func (d Data) GetInt(key string) int

func (Data) GetStr

func (d Data) GetStr(key string) string

func (Data) GetStrSlice

func (d Data) GetStrSlice(key string) []string

func (Data) Set

func (d Data) Set(key string, value interface{})

type Files

type Files []*os.File

type Logger

type Logger struct {
	log.Logger
}

func NewLogger

func NewLogger(module string) Logger

func (Logger) Errorf

func (l Logger) Errorf(format string, args ...interface{})

Jump to

Keyboard shortcuts

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