utils

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 15 Imported by: 17

Documentation

Index

Constants

View Source
const DefaultMetricPath = "/metrics"
View Source
const DefaultMetricPort = "3006"
View Source
const ErrorCode = -1

Variables

This section is empty.

Functions

func BigToHex

func BigToHex(bigInt big.Int) string

BigToHex covert big.Int to hexadecimal representation

func Bytes2BigInt

func Bytes2BigInt(bytes []byte) *big.Int

func Bytes2Hex

func Bytes2Hex(bytes []byte) string

func Bytes2HexP

func Bytes2HexP(bytes []byte) string

with prefix '0x'

func Debug

func Debug(format string, v ...interface{})

func DecimalToBigInt

func DecimalToBigInt(d decimal.Decimal) *big.Int

func Error

func Error(format string, v ...interface{})

func Hex2BigInt

func Hex2BigInt(str string) *big.Int

func Hex2Bytes

func Hex2Bytes(str string) []byte

func Hex2Int

func Hex2Int(hex string) uint64

just return uint64 type

func Info

func Info(format string, v ...interface{})

func Int2Bytes

func Int2Bytes(i uint64) []byte

func Int2Hex

func Int2Hex(number uint64) string

func IntToDecimal

func IntToDecimal(value interface{}) decimal.Decimal

func IntToHex

func IntToHex(i int) string

IntToHex convert int to hexadecimal representation

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func NumberToString

func NumberToString(number interface{}) string

func ParseInt

func ParseInt(number string, defaultNumber int) int

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes zero-pads slice to the right up to length l.

func StartMetrics added in v0.0.5

func StartMetrics()

func String2BigInt added in v0.0.3

func String2BigInt(str string) big.Int

func StringToDecimal

func StringToDecimal(str string) decimal.Decimal

To Decimal

func ToJsonString

func ToJsonString(o interface{}) string

Types

type HttpClient added in v0.0.3

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient added in v0.0.3

func NewHttpClient(transport *http.Transport) *HttpClient

func (*HttpClient) Delete added in v0.0.3

func (h *HttpClient) Delete(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*HttpClient) Get added in v0.0.3

func (h *HttpClient) Get(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*HttpClient) Post added in v0.0.3

func (h *HttpClient) Post(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*HttpClient) Put added in v0.0.3

func (h *HttpClient) Put(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)

func (*HttpClient) Request added in v0.0.3

func (h *HttpClient) Request(method, u string, params []KeyValue, requestBody interface{}, headers []KeyValue) (err error, code int, respBody []byte)

type IHttpClient added in v0.0.3

type IHttpClient interface {
	Request(method, url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Get(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Post(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Delete(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
	Put(url string, params []KeyValue, body interface{}, header []KeyValue) (error, int, []byte)
}

type KeyValue added in v0.0.3

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type MetricsHandler added in v0.0.5

type MetricsHandler struct {
}

func (MetricsHandler) ServeHTTP added in v0.0.5

func (MetricsHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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