utils

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decimal

func Decimal(value float64) float64

Decimal 保留两位小数

func EncryptPassword

func EncryptPassword(password, salt string) string

EncryptPassword 密码加密

func FileIsExisted

func FileIsExisted(filename string) bool

文件或文件夹是否存在

func GetBetweenDates

func GetBetweenDates(sdate, edate string) []string

GetBetweenDates 根据开始日期和结束日期计算出时间段内所有日期 参数为日期格式,如:2020-01-01

func GetCityByIp

func GetCityByIp(ip string) string

GetCityByIp 获取ip所属城市

func GetClientIp

func GetClientIp(ctx context.Context) string

GetClientIp 获取客户端IP

func GetDomain

func GetDomain(ctx context.Context) string

GetDomain 获取当前请求接口域名

func GetLocalIP

func GetLocalIP() (ip string, err error)

GetLocalIP 服务端ip

func GetQuarterDay

func GetQuarterDay() (string, string)

GetQuarterDay 获得当前季度的初始和结束日期

func GetTime

func GetTime(i int, types int, begin string) (startTime string, endTime string, duration int, unit string)

GetTime 根据类型和开始时间获取时间段及长度

func GetTimeByType

func GetTimeByType(types int) (index int, begin string, end string)

GetTimeByType 根据类型获取开始时间、结束时间及差值 1 天 2 周 3 月 4 年

func GetUserAgent

func GetUserAgent(ctx context.Context) string

GetUserAgent 获取user-agent

func GetWeekDay

func GetWeekDay() (string, string)

GetWeekDay 获取本周的开始时间和结束时间

func InArray

func InArray(target string, strArray []string) bool

InArray 判断字符串是否存在数组中

func MarkdownToHtml

func MarkdownToHtml(mdContent string) string

MarkdownToHtml 解析markdown为html

func ParseFilePath

func ParseFilePath(pathStr string) (fileName string, fileType string)

解析路径获取文件名称及后缀

func RemoveDuplicationMap

func RemoveDuplicationMap(arr []string) []string

RemoveDuplicationMap 数组去重

func RemoveRepeatedElementAndEmpty

func RemoveRepeatedElementAndEmpty(arr []int) []int

func ReplaceTemplate

func ReplaceTemplate(content string, variable map[string]interface{}) (result string, err error)

func WriteToFile

func WriteToFile(fileName string, content string) error

写入文件

Types

This section is empty.

Jump to

Keyboard shortcuts

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