common

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToFloat32

func ByteToFloat32(bytes []byte) float32

func ByteToFloat64

func ByteToFloat64(bytes []byte) float64

func Bytes2String

func Bytes2String(b []byte) string

func BytesToInt

func BytesToInt(buf []byte) int32

字节转换成整形

func BytesToInt16

func BytesToInt16(buf []byte) int16

字节转换成整形

func BytesToInt64

func BytesToInt64(buf []byte) int64

字节转整型

func Float32ToByte

func Float32ToByte(float float32) []byte

func Float64ToByte

func Float64ToByte(float float64) []byte

func GetFirstDateOfMonth added in v1.0.3

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetLastDateOfMonth added in v1.0.3

func GetLastDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetProgramPath

func GetProgramPath(path string) string

func GetZeroTime added in v1.0.3

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func Int64ToBytes

func Int64ToBytes(n int64) []byte

整型转字节

func IntToBytes

func IntToBytes(n int32) []byte

整形转换成字节

func InterfaceToNumeric

func InterfaceToNumeric(val interface{}) interface{}

此方法需要配合上面的 IsNumeric 一起使用

func IsNumeric

func IsNumeric(val interface{}) bool

func MustID

func MustID() uint64

Get unique id from Twitter's Snowflake

func NumberToString

func NumberToString(a interface{}) string

func PathExists

func PathExists(path string) (bool, error)

判断文件夹是否存在

func RandomString

func RandomString(n int) string

func String2Bytes

func String2Bytes(s string) []byte

Types

type HttpClient

type HttpClient struct {
	Host       string
	Port       int32
	AppKey     string
	AppSecret  string
	QueryNum   int
	IsHttps    bool
	HttpClient *http.Client
}

func (*HttpClient) HttpGet

func (hkHttp *HttpClient) HttpGet(path string, headers map[string]string, bodys map[string]string) ([]byte, error)

func (*HttpClient) HttpPost

func (hkHttp *HttpClient) HttpPost(path string, headers map[string]string, bodys map[string]string) ([]byte, error)

func (*HttpClient) HttpPostJson

func (hkHttp *HttpClient) HttpPostJson(path string, bodys string) ([]byte, error)

func (*HttpClient) Init

func (hkHttp *HttpClient) Init()

type SafeMutexMap

type SafeMutexMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New() *SafeMutexMap

func (*SafeMutexMap) Dump

func (s *SafeMutexMap) Dump(w io.Writer)

func (*SafeMutexMap) Get

func (s *SafeMutexMap) Get(key interface{}) interface{}

func (*SafeMutexMap) GetValue

func (s *SafeMutexMap) GetValue(key interface{}) (interface{}, bool)

func (*SafeMutexMap) Remove

func (s *SafeMutexMap) Remove(key interface{})

func (*SafeMutexMap) Set

func (s *SafeMutexMap) Set(key interface{}, value interface{})

Jump to

Keyboard shortcuts

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