util

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATE_TIME_FORMAT       = "2006-01-02 15:04:05"
	DATE_TIME_MONTH_FORMAT = "01-02 15:04:05"
	DATE_MINUTE_FORMAT     = "2006-01-02 15:04"
	DATE_FORMAT            = "2006-01-02"
)
View Source
const COL_A = 65

Variables

View Source
var Location *time.Location

Functions

func Delete added in v0.2.0

func Delete(slice []string, index int) (newSlice []string)

func Desensitize added in v0.4.0

func Desensitize(input string, keep ...int) string

脱敏

func ExcelExport added in v0.5.0

func ExcelExport(sheetName string, titleCols []string, colFieldMap map[string]string, values []interface{}, saveExcelFilePath string) error

func FindAddress

func FindAddress(ctx context.Context, ip string) (string, error)

func FormatDateTime added in v0.2.0

func FormatDateTime(timestamp int64) string

func FormatDateTimeMonth added in v0.2.0

func FormatDateTimeMonth(timestamp int64) string

func GenerateId

func GenerateId() string

func HttpDownloadFile

func HttpDownloadFile(ctx context.Context, fileURL string, proxyURL ...string) []byte

func HttpGet

func HttpGet(ctx context.Context, url string, header map[string]string, data g.Map, result interface{}, proxyURL ...string) error

func HttpPost

func HttpPost(ctx context.Context, url string, header map[string]string, data, result interface{}, proxyURL ...string) error

func HttpPostJson

func HttpPostJson(ctx context.Context, url string, header map[string]string, data, result interface{}, proxyURL ...string) error

func NewKey

func NewKey(prefix string, length int, ids ...string) string

func PriceConv added in v0.2.0

func PriceConv(ratio float64) float64

func QuotaConv added in v0.2.0

func QuotaConv(quota int) float64

func RenderTemplate

func RenderTemplate(data any) (string, error)

func Round added in v0.2.0

func Round(f float64, n int) float64

func ToMap

func ToMap[T any, K int | string](arr []T, fn func(T) K) map[K]T

切片转 Map

func Unique

func Unique[T IntInterface | string](data []T) []T

切片去重

func WebSocketClient

func WebSocketClient(ctx context.Context, wsURL string, messageType int, message []byte, result chan []byte, proxyURL ...string) (*websocket.Conn, error)

func WebSocketClientOnlyReceive

func WebSocketClientOnlyReceive(ctx context.Context, wsURL string, result chan []byte, proxyURL ...string) (*websocket.Conn, error)

Types

type DateTime

type DateTime struct {
	StartTimestamp int64
	EndTimestamp   int64
	StartDate      string
	StartDateTime  string
	EndDate        string
	EndDateTime    string
}

func Day

func Day(startTime, endTime string) (dateTimeList []*DateTime)

func MinuteRange

func MinuteRange(startTime, endTime int64) []*DateTime

func Month

func Month(startTime, endTime string) (dateTimeList []*DateTime)

func Week

func Week(startTime, endTime string) (dateTimeList []*DateTime)

type IntInterface

type IntInterface interface {
	uint | uint8 | uint16 | uint32 | uint64 | int | int8 | int16 | int32 | int64
}

type IpAddressResponse

type IpAddressResponse struct {
	Code   string `json:"resultcode"`
	Reason string `json:"reason"`
	Result struct {
		Country  string `json:"Country"`
		Province string `json:"Province"`
		City     string `json:"City"`
		Isp      string `json:"Isp"`
	} `json:"result"`
	ErrorCode int `json:"error_code"`
}

Jump to

Keyboard shortcuts

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