util

package
v0.0.0-...-299ffca Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TimeFmtLong yyyy-MM-dd hh:mm:ss
	TimeFmtLong = `2006-01-02 15:04:05`
	// TimeFmtNumeric yyyyMMddhhmmss
	TimeFmtNumeric = `20060102150405`

	// DateFmtLong yyyy-MM-dd
	DateFmtLong = `2006-01-02`
	// DateFmtNumeric yyyyMMdd
	DateFmtNumeric = `20060102`
)

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation.

func IsDate

func IsDate(s string) bool

IsDate 是否为有效日期

func IsDigit

func IsDigit(s string) bool

IsDigit 字符串是否数字

func IsTime

func IsTime(s string) bool

IsTime 是否时间格式字符串

func IsWeekEnd

func IsWeekEnd(d time.Weekday) bool

IsWeekEnd 日期是否周末

func Random

func Random(n int) string

Random 指定长度的随机字符串(字母或数字)

func StrFmtTime

func StrFmtTime(s, fmt string) (t time.Time, err error)

StrFmtTime 时间转字符串

func StrLen

func StrLen(s string) int

StrLen utf8 string length

func StrMax

func StrMax(s string, max int) bool

StrMax verify string's max lenth

func StrMin

func StrMin(s string, min int) bool

StrMin verify string's min lenth

func StrRange

func StrRange(s string, min, max int) bool

StrRange verify string's Range lenth

func StrToDate

func StrToDate(s string) (t time.Time, err error)

StrToDate 字符串转日期

func StrToTime

func StrToTime(s string) (t time.Time, err error)

StrToTime 字符串转时间

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without a memory allocation.

func TimeFmtStr

func TimeFmtStr(t time.Time, fmt string) string

TimeFmtStr 时间转字符串

func TimeToStr

func TimeToStr(t time.Time) string

TimeToStr 时间转字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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