Code Monkey home page Code Monkey logo

helper's Introduction

Helper

2.一些常用的助手函数工具包

包含:

字符串 (TStr)

数组 (TArr)

整型 (TInt)

浮点型 (TFloat)

文件 (TFile)

url (TUri)

hash (THash)

动态调用方法 (TCallFunc)

debug (TDebug)

os (TOs)

类型转换 (TConv)

时间 (TTime)

定时任务 (TCorn)

uuid (TUuid)

json (TJson)

加解密 (TEncrypt)

以上操作☝☝☝

3.获取 ❤❤❤

go version >= 1.15

go get github.com/go-assist/helper

4. 示例 for example
package helper

import (
	"fmt"
	"github.com/go-assist/helper"
)

func example() {
	// string
	s1 := `123456`
	md5 := helper.TStr.MD5(s1)
	fmt.Println(md5) // E10ADC3949BA59ABBE56E057F20F883E

	s2 := `hello world`
	ucFirst := helper.TStr.UcFirst(s2)
	fmt.Println(ucFirst) // Hello world

	sfx := helper.TStr.Shuffle(s1)
	fmt.Println(sfx) // 125436

	// array
	arr := [5]int{1, 2, 3, 4, 5}
	i := 2
	if helper.TArr.InArray(i, arr) {
		fmt.Printf(" %v in %v \n", i, arr) //  2 in [1 2 3 4 5]
	}

	// debug
	funcName := helper.TDebug.GetFuncName(helper.TArr.ArrayDiff, true) // ...ArrayDiff-fm
	fmt.Println(funcName) // ArrayDiff-fm

	// float
	round := helper.TFloat.Round(4.56)
	fmt.Println(round) // 4

	// json
	jsonArr := `[{"email_address":"[email protected]"},{"email_address":"[email protected]"}]`
	m := helper.TJson.JsonToMapArr(jsonArr)
	fmt.Println(m) // [map[email_address:[email protected]] map[email_address:[email protected]]]

	// convert
	inter := helper.TConv.Int2Str(s1)
	fmt.Println(inter) // 123456

	// hash, 此方法可以用来获取0-100区间的随机值
	h := "abc123tre"
	hashcode := helper.THash.HashCode(h, 2)
	fmt.Println(hashcode) // 52 

	// os
	endian := helper.TOs.GetEndian()
	fmt.Println(endian) // LittleEndian

	// file
	f := "./testname.txt"
	fileName := helper.TFile.Basename(f)
	fmt.Println(fileName) // testname.txt

	// encrypt
	ek := "Key"
	enc := helper.TEncrypt.EasyEncrypt(s1, ek)
	fmt.Println(enc) // 89735695aWtqZ2ps
	dec := helper.TEncrypt.EasyDecrypt(enc, ek)
	fmt.Println(dec) // 123456

	// url
	uri := `http://localhost/report?Av=5.3.5&Bd=bdtest&Cid=023&CityCode=101030100&Did=70836bc3ae68fddbc78ce5a917ae9e9d60c712df&Imei=`
	qm := helper.TUri.ParseUriQueryToMap(uri)
	fmt.Println(qm) // map[Av:5.3.5 Bd:bdtest Cid:023 CityCode:101030100 Did:70836bc3ae68fddbc78ce5a917ae9e9d60c712df Imei:]
	
	// int
	abs := helper.TInt.Abs(-1)
	fmt.Println(abs) // 1
	
	// time
	days := helper.TTime.GetMonthDays(2)
	fmt.Println(days) // 28
	
	// validate
	isEven := helper.TInt.IsEven(3)
	fmt.Println(isEven) // false
	
	// zlib string
	zip, _ := helper.TStr.DoZlibCompress([]byte(`我是一只小小的goper,写呀写呀写bug`))
	fmt.Println(zip)
	unzip, _ := helper.TStr.DoZlibUnCompress(zip)
	unzipString := string(unzip)
	fmt.Println(unzipString)
	
	// ... other 
}
5. 使用过程如有疑问欢迎issue 。◕‿◕。

helper's People

Contributors

go-assist avatar inanyworld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

helper's Issues

同学,您这个项目引入了20个开源组件,存在1个漏洞,辛苦升级一下

检测到 golangtoolkit/helper 一共引入了20个开源组件,存在1个漏洞

漏洞标题:GJSON 安全漏洞
缺陷组件:github.com/tidwall/[email protected]
漏洞编号:CVE-2021-42836
漏洞描述:Tidwall Gjson是Tidwall个人开发者的一个基于Go语言的用于与json格式数据进行交互的代码库。
GJSON 存在安全漏洞,该漏洞源于1.9.3之前的GJSON允许ReDoS(正则表达式拒绝服务)攻击。
影响范围:(∞, 1.9.3)
最小修复版本:1.9.3
缺陷组件引入路径:github.com/golangtoolkit/helper@->github.com/tidwall/[email protected]

另外还有几个漏洞,详细报告:https://mofeisec.com/jr?p=ab3f62

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.