utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

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 Debugf

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

func DecimalToBigInt

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

func Errorf

func Errorf(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 Infof

func Infof(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

func StartMetrics()

func String2BigInt

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

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

func NewHttpClient

func NewHttpClient(transport *http.Transport) *HttpClient

func (*HttpClient) Delete

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

func (*HttpClient) Get

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

func (*HttpClient) Post

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

func (*HttpClient) Put

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

func (*HttpClient) Request

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

type IHttpClient

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

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

type MetricsHandler

type MetricsHandler struct {
}

func (MetricsHandler) ServeHTTP

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