util

package
v2.0.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: MIT Imports: 6 Imported by: 105

Documentation

Overview

Package util defines some utility functions for Golang.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteString

func ByteString(b []byte) string

ByteString converts []byte to string without memory allocation by block magic

func FromUint32

func FromUint32(b []byte, i uint32)

FromUint32 translates uint32 to 4 byte

func GetDateBytes

func GetDateBytes(buf []byte, year int, month int, day int) []byte

GetDateBytes returns the []byte representation of year, month and day. The format of []byte returned is 20060102 buf length must be greater than or equal to 8

func GetIntBytes

func GetIntBytes(buf []byte, i int64) []byte

GetIntBytes returns the []byte representation of i in base 10. buf length must be greater than or equal to 20

func GetNsecBytes

func GetNsecBytes(buf []byte, nsec int) []byte

GetNsecBytes returns the []byte representation of nsec. The format of []byte returned is 123, 123456 or 123456789 buf length must be greater than or equal to 9

func GetTimeBytes

func GetTimeBytes(buf []byte, hour int, min int, sec int) []byte

GetTimeBytes returns the []byte representation of hour, min and sec. The format of []byte returned is 150405 buf length must be greater than or equal to 6

func GetUintBytes

func GetUintBytes(buf []byte, u uint64) []byte

GetUintBytes returns the []byte representation of u in base 10. buf length must be greater than or equal to 20

func Itoa

func Itoa(i int) string

Itoa returns the string representation of i

func LocalProxy

func LocalProxy(proxy, local interface{}) error

LocalProxy make a local object to a proxy struct

func Max

func Max(a, b int) int

Max returns the max one of a, b

func Min

func Min(a, b int) int

Min returns the min one of a, b

func StringByte

func StringByte(s string) []byte

StringByte converts string to string without memory allocation by block magic

func ToUint32

func ToUint32(b []byte) uint32

ToUint32 translates 4 byte to uint32

func UTF16Length

func UTF16Length(str string) (n int)

UTF16Length return the UTF16 length of str. str must be an UTF8 encode string, otherwise return -1.

func UUIDv4

func UUIDv4() (uid string)

UUIDv4 returns a version 4 UUID string

Types

This section is empty.

Jump to

Keyboard shortcuts

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