yiigo

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OK defines for string `OK`
	OK = "OK"

	// Default defines for `default` name
	Default = "default"
)

Variables

This section is empty.

Functions

func AddSlashes

func AddSlashes(s string) string

AddSlashes 在字符串的每个引号前添加反斜杠

func CreateFile

func CreateFile(filename string) (*os.File, error)

CreateFile 创建或清空指定的文件 文件已存在,则清空;文件或目录不存在,则以0775权限创建

func Date

func Date(timestamp int64, format ...string) string

Date 格式化时间戳;默认格式:2006-01-02 15:04:05 若 timestamp < 0,则使用 `time.Now()`

func IP2Long

func IP2Long(ip string) uint32

IP2Long IP地址转整数

func LoadCertFromPfxFile

func LoadCertFromPfxFile(pfxFile, password string) (tls.Certificate, error)

LoadCertFromPfxFile 通过pfx(p12)文件生成TLS证书 注意:证书需采用「TripleDES-SHA1」加密方式

func Long2IP

func Long2IP(ip uint32) string

Long2IP 整数转IP地址

func MarshalNoEscapeHTML

func MarshalNoEscapeHTML(v any) ([]byte, error)

MarshalNoEscapeHTML 不带HTML转义的JSON序列化

func OpenFile

func OpenFile(filename string) (*os.File, error)

OpenFile 打开指定的文件 文件已存在,则追加内容;文件或目录不存在,则以0775权限创建

func QuoteMeta

func QuoteMeta(s string) string

QuoteMeta 在字符串预定义的字符前添加反斜杠

func SetTimezone

func SetTimezone(loc *time.Location)

SetTimezone 设置时区;默认:GMT+8

func SliceRand

func SliceRand[T any](a []T, n int) []T

SliceRand 返回一个指定随机挑选个数的切片 若 n == -1 or n >= len(a),则返回打乱的切片

func SliceUniq

func SliceUniq[T ~int | ~int64 | ~float64 | ~string](a []T) []T

SliceUniq 切片去重

func StrToTime

func StrToTime(datetime string, format ...string) int64

StrToTime 解析时间字符串为时间戳;默认格式:2006-01-02 15:04:05

func StripSlashes

func StripSlashes(s string) string

StripSlashes 删除字符串中的反斜杠

func VersionCompare

func VersionCompare(rangeVer, curVer string) (bool, error)

VersionCompare 语义化的版本比较,支持:>, >=, =, !=, <, <=, | (or), & (and). 参数 `rangeVer` 示例:1.0.0, =1.0.0, >2.0.0, >=1.0.0&<2.0.0, <2.0.0|>3.0.0, !=4.0.4

func WeekAround

func WeekAround(timestamp int64, format ...string) (monday, sunday string)

WeekAround 返回给定时间戳所在的周的「周一」和「周日」;默认格式:2006-01-02 15:04:05

Types

type CDATA

type CDATA string

CDATA XML `CDATA` 标记

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML XML 带 `CDATA` 标记序列化

type X

type X map[string]any

X `map[string]any` 的别名.

Jump to

Keyboard shortcuts

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