util

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const EndTime = " 23:59:59"
View Source
const GinUtilKey = "GinUtilKey"
View Source
const StartTime = " 00:00:00"
View Source
const TimeFormat = YearMonthDayDateTime

TimeFormat 格式必须如下1个字符也不要动!

View Source
const UserIdKey = "userId"
View Source
const Year = "2006"
View Source
const YearMonth = "2006-01"
View Source
const YearMonthDay = "2006-01-02"
View Source
const YearMonthDayDateTime = "2006-01-02 15:04:05"

YearMonthDayDateTime 年月日

Variables

View Source
var GinUtil = context.Background()

Functions

func CreateFile

func CreateFile(path string) *os.File

func FileCreateDirectory

func FileCreateDirectory(path string)

func FileDirectoryPath

func FileDirectoryPath(path string) string

FileDirectoryPath 返回一个目录格式 /user/xx.txt => /user/

func FileMerge

func FileMerge(fileName, targetPath, timestamp, path string)

FileMerge 指定合并某个目录下的文件,合并文件

func FilePathName

func FilePathName(path string) string

FilePathName 返回一个文件名 /user/xx.txt => xx.txt or xx.txt => xx.txt

func FilePathSeparator

func FilePathSeparator() string

FilePathSeparator 获取系统路径分割符号 linux = / or win =\\

func FileReadByte

func FileReadByte(file *os.File) []byte

FileReadByte 读取文件

func GetFilePath

func GetFilePath(path string) string

GetFilePath 返回一个目录格式 /user/xx.txt => /user/ 请使用:FileDirectoryPath Deprecated

func GetFilePathName

func GetFilePathName(path string) string

GetFilePathName 返回一个文件名 /user/xx.txt => xx.txt or xx.txt => xx.txt 请使用 FilePathName Deprecated

func GetGinContext

func GetGinContext() *gin.Context

GetGinContext 获取 GinContext 上下文 请使用: GinGetContext Deprecated

func GetIp

func GetIp() []string

GetIp 获取ip 192.168.16.100/24

func GetMonthEndDate

func GetMonthEndDate() string

GetMonthEndDate 获取当前月结束日期 示例: 2006-02-12 => 2006-02-30

func GetMonthStartDate

func GetMonthStartDate() string

GetMonthStartDate 获取当前月开始日期 示例: 2006-02-12 => 2006-02-01

func GetParamsUrlPah

func GetParamsUrlPah() string

GetParamsUrlPah 带参数的 /user/test?name=xx 请使用: GinParamsUrlPah Deprecated

func GetPathSeparator

func GetPathSeparator() string

GetPathSeparator 获取系统路径分割符号 linux = / or win =\\ 请使用 FilePathSeparator Deprecated

func GetTargetMaskIp

func GetTargetMaskIp(digit interface{}) []string

GetTargetMaskIp 获取指定掩码位数的ip 8 16 24 32 分割/ 192.168.16.100/24 => 192.168.16.100

func GetTodayDate

func GetTodayDate() string

GetTodayDate 获取当前日期 2006-01-02

func GetTodayDateTime

func GetTodayDateTime() string

GetTodayDateTime 获取当前日期时间 2006-01-02 15:04:05

func GetTodayEndDate

func GetTodayEndDate() string

GetTodayEndDate 获取当前日期 2006-01-02 23:59:59

func GetTodayMillisecondTimestamp

func GetTodayMillisecondTimestamp() int64

GetTodayMillisecondTimestamp 获取当前时间13位时间戳,毫秒

func GetTodayStartDate

func GetTodayStartDate() string

GetTodayStartDate 获取当前日期 2006-01-02 00:00:00

func GetTodayTimestamp

func GetTodayTimestamp() int64

GetTodayTimestamp 获取当前时间10位时间戳,秒

func GetToken

func GetToken(id interface{}) string

func GetTokenParse

func GetTokenParse(t string) string

GetTokenParse 获取token解析

func GetUrlPath

func GetUrlPath() string

GetUrlPath 不带参数的 /user/test?name=xx => /user/test 请使用: GinUrlPath Deprecated

func GetUserId

func GetUserId(t string) string

GetUserId 获取token解析,请使用 GetTokenParse 替代 Deprecated

func GetYearEndDate

func GetYearEndDate() string

GetYearEndDate 获取当前年结束日期 示例: 2006-02-12 => 2006-12-31

func GetYearStartDate

func GetYearStartDate() string

GetYearStartDate 获取当前年开始日期 示例: 2006-02-12 => 2006-01-01

func GinGetContext

func GinGetContext() *gin.Context

func GinParamsUrlPah

func GinParamsUrlPah() string

GinParamsUrlPah 带参数的 /user/test?name=xx

func GinSetContext

func GinSetContext(c *gin.Context)

GinSetContext 设置 GinContext 上下文

func GinUrlPath

func GinUrlPath() string

GinUrlPath 不带参数的 /user/test?name=xx => /user/test

func JsonToObj

func JsonToObj(jsonStr string, v interface{})

JsonToObj Json转换成对象 => 传参需要带&号 示例=> (jsonStr,&user)

func JsonToStr

func JsonToStr(v interface{}) string

JsonToStr 把对象转换Json字符串!

func Md5Encode

func Md5Encode(v interface{}) string

Md5Encode md5编码只有加密

func Mkdir

func Mkdir(path string)

Mkdir 创建目录,会排除/user/xx.txt ,则创建user目录 请使用: FileCreateDirectory Deprecated

func OpenFile

func OpenFile(path string) *os.File

OpenFile open File

func ParseTime

func ParseTime(t string) time.Time

ParseTime 解析10位时间戳,返回日期对象

func ParseTimeStr

func ParseTimeStr(t interface{}) string

ParseTimeStr 解析10位时间戳,返回格式好的日期格式 2006-01-02 15:04:05

func ParseTimeStrAndFormatStr

func ParseTimeStrAndFormatStr(t interface{}, f string) string

ParseTimeStrAndFormatStr 解析10位时间戳

func RandomNumber added in v0.1.0

func RandomNumber(length int) string

RandomNumber 获取指定长度的随机数字字符串 输入 5 返回 16523

func RandomRangeNum added in v0.1.0

func RandomRangeNum(max int) int

RandomRangeNum 获取指定返回的数字 输入 30 返回 0-29

func RandomRangeNumPlus added in v0.1.0

func RandomRangeNumPlus(min, max int) int

RandomRangeNumPlus 获取指定返回的数字 输入 10,30 返回 10-29

func RandomString added in v0.1.0

func RandomString(length int) string

RandomString 获取指定长度的随机字符串 输入 3 返回 xna

func ReadFile

func ReadFile(path string) []byte

ReadFile read File

func SendCode

func SendCode(code string, tel string)

func SetGinContext

func SetGinContext(c *gin.Context)

SetGinContext 设置 GinContext 上下文 请使用: GinSetContext Deprecated

func URLDecode

func URLDecode(str string) string

URLDecode 解码网址

func URLEncode

func URLEncode(str string) string

URLEncode 编码网址

Types

type FileInfo

type FileInfo struct {
	// 文件名
	FileName string `from:"fileName" json:"fileName"`
	// 1 是目录,0 默认文件
	IsDirectory int8 `from:"isDirectory" json:"isDirectory"`
}

func ListFile

func ListFile(path string) []FileInfo

type Rsa

type Rsa struct {
	PrivateKey string
	PublicKey  string
}

Rsa 存放私钥和公钥的对象

func RsaCreate

func RsaCreate() *Rsa

RsaCreate 获取Rsa秘钥对象

func (*Rsa) RsaDecode

func (r *Rsa) RsaDecode(v string) string

RsaDecode rsa使用私钥解码

func (*Rsa) RsaEncode

func (r *Rsa) RsaEncode(v interface{}) string

RsaEncode rsa使用公钥编码

Jump to

Keyboard shortcuts

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