utils

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 26 Imported by: 5

Documentation

Index

Constants

View Source
const (
	TimeLayout = "2006-01-02 15:04:05"
	DateLayout = "2006-01-02"
)

Variables

View Source
var NamingStrategy schema.NamingStrategy
View Source
var StatusUnauthorized = errors.New("Unauthorized")

Functions

func ArrayToString

func ArrayToString(array []string) string

ArrayToString 数组转字符串,元素之间用逗号隔开

func BigCamelName

func BigCamelName(s string) string

BigCamelName 转大驼峰式命名 例如helloWorld -> HelloWorld

func CalcFileMD5

func CalcFileMD5(file io.Reader) (string, error)

CalcFileMD5 计算文件的MD5值

func CheckSN

func CheckSN(snStr string) error

CheckSN 校验序列号

func ConvertBD09ToGCJ02

func ConvertBD09ToGCJ02(lat, lon float64) (float64, float64)

* * 坐标转换,百度地图坐标转换成腾讯地图坐标 * @param lat 百度坐标纬度 * @param lon 百度坐标经度 * @return 返回结果:纬度,经度

func ConvertGCJ02ToBD09

func ConvertGCJ02ToBD09(lat, lon float64) (float64, float64)

* * 坐标转换,腾讯地图转换成百度地图坐标 * @param lat 腾讯纬度 * @param lon 腾讯经度 * @return 返回结果:经度,纬度

func Cors

func Cors() gin.HandlerFunc

处理跨域请求,支持options访问

func DateStringToUnix

func DateStringToUnix(str string) int64

DateStringToUnix 日期字符串转时间戳

func ExtractFileNameAndType

func ExtractFileNameAndType(str string) (string, string)

ExtractFileNameAndType 提取文件名和文件类型

func FormatDate

func FormatDate(date time.Time) string

FormatDate time.Time转日期字符串 格式2006-01-02

func FormatSqlNullDate

func FormatSqlNullDate(t sql.NullTime) string

FormatSqlNullDate sql.NullTime转日期字符串 格式2006-01-02

func FormatSqlNullTime

func FormatSqlNullTime(t sql.NullTime) string

FormatSqlNullTime sql.NullTime转时间字符串 格式2006-01-02 15:04:05

func FormatTime

func FormatTime(date time.Time) string

FormatTime time.Time转时间字符串 格式2006-01-02 15:04:05

func GenMac

func GenMac(mac int64) string

GenMac 生成Mac地址

func GenSN

func GenSN(sn int64) string

GenSN 生成10位序列号

func GenSN64

func GenSN64(sn int64) string

GenSN64 生成18位序列号

func GenShortID

func GenShortID(prefix string) string

GenShortID 生成15位短ID

func GenerateOrderString

func GenerateOrderString(str, defaultSort string) (string, error)

func Get

func Get(url string, response interface{}, tlsConfig *tls.Config, setHeader func(req *http.Request) error) error

func GetByWebService

func GetByWebService(url string, response interface{}, tlsConfig *tls.Config, setHeader func(req *http.Request) error) error

func GetFileExtensionByLanguage

func GetFileExtensionByLanguage(language string) string

GetFileExtensionByLanguage 根据编程语言获取文件后缀名

func GetHardDriveSerial

func GetHardDriveSerial() (string, error)

GetHardDriveSerial 获取硬盘序列号

func GetMotherboardSerial

func GetMotherboardSerial() (string, error)

GetMotherboardSerial 获取主板序列号

func JsonToStringArray

func JsonToStringArray(str string) []string

JsonToStringArray json字符串转字符串数组

func LcFirst

func LcFirst(s string) string

LcFirst 转小驼峰式命名 例如HelloWorld -> helloWorld

func LowerSnakeCase

func LowerSnakeCase(s string) string

LowerSnakeCase 转小写蛇式命名

func ObjectToJsonString

func ObjectToJsonString(obj interface{}) string

ObjectToJsonString 对象转json字符串

func ParseDate

func ParseDate(str string) time.Time

ParseDate 日期字符串转time.Time

func ParseSqlNullDate

func ParseSqlNullDate(str string) sql.NullTime

ParseSqlNullDate 日期字符串转sql.NullTime

func ParseSqlNullTime

func ParseSqlNullTime(str string) sql.NullTime

ParseSqlNullTime 时间字符串转sql.NullTime

func ParseTime

func ParseTime(str string) time.Time

ParseTime 时间字符串转time.Time

func ParseTime2

func ParseTime2(str string) time.Time

ParseTime2 时间字符串(结尾加上23:59:59)转time.Time

func ParseTimeWithLayout

func ParseTimeWithLayout(str, layout string) time.Time

func Post

func Post(url string, body io.Reader, response interface{}, tlsConfig *tls.Config, setHeader func(req *http.Request) error) error

func PostByWebService

func PostByWebService(url string, body io.Reader, response interface{}, tlsConfig *tls.Config, setHeader func(req *http.Request) error) error

func RemoveLastCharS

func RemoveLastCharS(s string) string

RemoveLastCharS 移除最后一个s字符

func SetLogFileName

func SetLogFileName(name string)

func SetWriteLogFunc

func SetWriteLogFunc(w WriteLog)

func StringToArray

func StringToArray(str string) []string

StringToArray 字符串转字符串数组,元素之间用逗号隔开

func TimeStringToUnix

func TimeStringToUnix(str string) int64

TimeStringToUnix 时间字符串转时间戳

func ToTableName

func ToTableName(str string) string

ToTableName 转成数据库表名

func ToUpper

func ToUpper(str string) string

ToUpper 转大写

func UnixToDateString

func UnixToDateString(n int64) string

UnixToDateString 时间戳转日期字符串 格式2006-01-02

func UnixToTimeString

func UnixToTimeString(n int64) string

UnixToTimeString 时间戳转时间字符串 格式2006-01-02 15:04:05

func UpperSnakeCase

func UpperSnakeCase(s string) string

UpperSnakeCase 转大写蛇式命名

Types

type CPUInfoProvider

type CPUInfoProvider interface {
	GetSerialNumber() (string, error)
}

func GetCPUInfoProvider

func GetCPUInfoProvider() CPUInfoProvider

GetCPUInfoProvider 根据运行时环境返回相应平台的CPUInfoProvider实例

type IconFont

type IconFont struct {
	Key   string `json:"key"`
	Label string `json:"label"`
}

func GenIconFont

func GenIconFont(fileName string) []IconFont

type LinuxCPUInfoProvider

type LinuxCPUInfoProvider struct{}

LinuxCPUInfoProvider 用于获取Linux平台上的CPU信息

func (*LinuxCPUInfoProvider) GetSerialNumber

func (l *LinuxCPUInfoProvider) GetSerialNumber() (string, error)

type MacOSCPUInfoProvider

type MacOSCPUInfoProvider struct{}

MacOSCPUInfoProvider 用于获取macOS平台上的CPU信息

func (*MacOSCPUInfoProvider) GetSerialNumber

func (m *MacOSCPUInfoProvider) GetSerialNumber() (string, error)

type WindowsCPUInfoProvider

type WindowsCPUInfoProvider struct{}

WindowsCPUInfoProvider 用于获取Windows平台上的CPU信息

func (*WindowsCPUInfoProvider) GetSerialNumber

func (w *WindowsCPUInfoProvider) GetSerialNumber() (string, error)

type WriteLog

type WriteLog func(data []byte) error

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

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