fun

package
v0.0.0-...-0046c35 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeLacal = "Asia/Shanghai"

Functions

func Addslashes

func Addslashes(str string) string

addslashes() 函数返回在预定义字符之前添加反斜杠的字符串。 预定义字符是: 单引号(') 双引号(") 反斜杠(\)

func AesDecrypt

func AesDecrypt(crypto, key string) string

AesDecrypt AES解密

func AesEncrypt

func AesEncrypt(orig, key string) string

AesEncrypt AES加密

func ArrayKeys

func ArrayKeys(m map[string]interface{}) []string

func Base64Decode

func Base64Decode(sEnc string, security bool) string

Base64Decode base64_decode

func Base64Encode

func Base64Encode(sDec string, security bool) string

Base64Encode base64_encode

func Base64UrlDecode

func Base64UrlDecode(uEnc string) string

Base64UrlDecode Base64urldecode

func Base64UrlDecodePlus

func Base64UrlDecodePlus(str string) string

Base64UrlDecodePlus urldecode处理加号

func Base64UrlEncode

func Base64UrlEncode(uDec string) string

Base64UrlEncode Base64urlencode

func Base64UrlEncodePlus

func Base64UrlEncodePlus(str string) string

Base64UrlEncodePlus urlencode处理加号

func BirthdayToAge

func BirthdayToAge(birthday time.Time) int

BirthdayToAge 根据出生年月计算年龄

func ChunkSplit

func ChunkSplit(body string, chunklen uint, end string) string

ChunkSplit 字符串间隔插入字符

func ClearEmptySliceString

func ClearEmptySliceString(slice []string) []string

ClearEmptySliceString 去除slice的0值

func ClearTags

func ClearTags(str string) string

ClearTags 清除代码

func ClearZeroSliceInt

func ClearZeroSliceInt(slice []int) []int

ClearZeroSliceInt 去除slice的0值

func ClientIP

func ClientIP(r *http.Request, isCDN bool) string

func DateToWeek

func DateToWeek(t time.Time) int

DateToWeek 时间转数字,周日=7

func Decrypt

func Decrypt(textByte []byte, key string) string

Decrypt 可逆解密

func DefaultInt

func DefaultInt(i, def int) int

func Download

func Download(url, local string) error

func Encrypt

func Encrypt(text string, key string) []byte

Encrypt 可逆加密

func FileExists

func FileExists(path string) bool

判断文件是否存在

func FileMD5

func FileMD5(path string) (string, error)

func FilterNumber

func FilterNumber(str string) string

FilterNumber 过滤字符串中的数字

func HideString

func HideString(str string, starNum int) string

func If2Bool

func If2Bool(condition bool, yes bool, no bool) bool

func If2Int

func If2Int(condition bool, yes int, no int) int

func If2String

func If2String(condition bool, yes string, no string) string

代替三元表达式

func InSliceInt

func InSliceInt(value int, slice []int) bool

func InSliceString

func InSliceString(value string, slice []string) bool

func InSliceUint

func InSliceUint(value uint, slice []uint) bool

func IntChecked

func IntChecked(selectInt int, sumInt int) bool

IntChecked 值是否存在

func IsChineseAndEnglish

func IsChineseAndEnglish(str string, dot bool) bool

IsChineseAndEnglish 判断是否只有中英文和_

func LocalTime

func LocalTime(dt time.Time) string

func LocalTimeStr

func LocalTimeStr(rowValue string, utc string) string

func MD5

func MD5(text string) string

MD5 md5

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PregMatch

func PregMatch(pattern string, subject string, matches *[]string) bool

func PregMatchAll

func PregMatchAll(pattern string, subject string, matches *[][]string) bool

func PregReplace

func PregReplace(arr []string, repl interface{}, src string) string

PregReplace 正则替换 arr 正则表达式数组 repl 替换的内容,可以是字符串,也可以是字符串数组 src 要替换的字符串

func RandInt

func RandInt(n int64) int64

RandInt 生成指定位的随机整数

func Read

func Read(path string) string

func ReadDir

func ReadDir(path string, pre string) ([]string, []string)

遍历文件夹和文件

func Round

func Round(f float64, n int) float64

Round 小数点四舍五入

func Rsa2Sign

func Rsa2Sign(data string, privateKey []byte) string

Rsa2Sign RSA2签名

func SHA256

func SHA256(text string) string

SHA256 sha256

func SliceUniqueInt

func SliceUniqueInt(value []int) []int

SliceUniqueInt Int切片去重

func SliceUniqueString

func SliceUniqueString(value []string) []string

SliceUniqueString String切片去重

func SliceUniqueUint

func SliceUniqueUint(value []uint) []uint

SliceUniqueUint Uint切片去重

func StrReverse

func StrReverse(s string) string

StrReverse 字符串逆序

func StrTime

func StrTime(stringTime string, layout ...string) (time.Time, error)

func StrTimestamp

func StrTimestamp(stringTime string) int

func StripTags

func StripTags(str string) string

StripTags strip_tags

func Stripos

func Stripos(str string, index string) int

stripos 查找字符串在另一字符串中第一次出现的位置(不区分大小写)

func Stripslashes

func Stripslashes(str string) string

stripslashes() 函数删除由 addslashes() 函数添加的反斜杠。

func Strpos

func Strpos(str string, index string) int

strpos 查找字符串在另一字符串中第一次出现的位置(区分大小写)

func Strripos

func Strripos(str string, index string) int

strripos 查找字符串在另一字符串中最后一次出现的位置(不区分大小写)

func Strrpos

func Strrpos(str string, index string) int

strrpos 查找字符串在另一字符串中最后一次出现的位置(区分大小写)

func Struct2Map

func Struct2Map(obj interface{}, tag string) map[string]interface{}

func Struct2Str

func Struct2Str(obj interface{}, tag string) string

func Struct2Url

func Struct2Url(obj interface{}, tag string, isEnc bool) string

func SubStr

func SubStr(str string, start int, length int) string

substr 截取字符串,支持中文

func TimeSub

func TimeSub(t1, t2 time.Time) (int, int)

func Timestamp

func Timestamp(dt time.Time) int

func TimestampStr

func TimestampStr(dateline int64, format ...string) string

func TimestampTime

func TimestampTime(dateline int64, fix bool, offset ...int64) time.Time

func Unzip

func Unzip(zipFile, dest string, exclude []string) error

func UrlDecode

func UrlDecode(uEnc string) string

UrlDecode W3C

func UrlDecodePlus

func UrlDecodePlus(uEnc string) string

UrlDecodePlus //RFC 2396

func UrlEncode

func UrlEncode(uDec string) string

UrlEncode W3C

func UrlEncodePlus

func UrlEncodePlus(uDec string) string

UrlEncodePlus //RFC 2396

func Write

func Write(path, str string)

Types

type JsonASCII

type JsonASCII string

func (JsonASCII) MarshalJSON

func (esc JsonASCII) MarshalJSON() ([]byte, error)

type MapKV

type MapKV struct {
	Key   string
	Value int
}

type MapKVList

type MapKVList []MapKV

func SortMapByValue

func SortMapByValue(m map[string]int) MapKVList

SortMapByValue todo 有问题 SortMapByValue 对map按照value进行排序

func (MapKVList) Len

func (p MapKVList) Len() int

func (MapKVList) Less

func (p MapKVList) Less(i, j int) bool

func (MapKVList) Swap

func (p MapKVList) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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