func getUUID() (uuid string) { b := make([]byte, 16) fmt.Println(b) _, err := rand.Read(b) if err != nil { log.Fatal(err) } uuid = fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:]) return } func main() { uuid := getUUID()...
uuidObject, err := uuid.FromString(s) iferr !=nil{ log.Fatalf("failed to parse UUID %q: %v", s, err) } fmt.Println("successfully parsed UUID Version", uuidObject) 完整代码 点击展开 // blog: https://www.cnblogs.com/zichliang package main import ( "fmt" uuid "github.com/satori...
go get -u -v github.com/google/uuid package mainimport("crypto/md5""fmt""github.com/google/uuid""io""log") func strToMd5(data string) string { t :=md5.New() io.WriteString(t, data)returnfmt.Sprintf("%x", t.Sum(nil)) } func main() {//V1 基于时间 u1, err :=uuid.NewUUI...
问在golang中使用UUID生成唯一文件名ENUUID含义是通用唯一识别码 (Universally Unique Identifier),这 是...
Golang工具集-String工具,时间工具,http工具等 gotool === gotool是一个小而全的Golang工具集,主要是将日常开发中常用的到方法进行提炼集成,避免重复造轮子,提高工作效率,每一个方法都是作者经过工作经验,和从以往的项目中提炼出来的。 2021-7-9更新内容详细使用请看文档 添加文件...
NextCode() string } 3.ID生成 // 执行lua脚本获取id func execute(conf Config) string { luaId := redis.NewScript(` local id_key = KEYS[1] local initial = ARGV[1] local step = ARGV[2] local current = redis.call('get', id_key) ...
"github.com/google/uuid" ) func main() { fmt.Println(uuid.NewString()) // 打开pcap文件 handle, _ := pcap.OpenOffline("web1.pcap") defer handle.Close() // Loop through packets in file packetSource := gopacket.NewPacketSource(handle, handle.LinkType()) ...
uuid "github.com/satori/go.uuid" ) func main() { uuid := uuid.NewV4() fmt.Printf("%s", uuid) } 5. 数组字典和循环 直接看代码就是了。 package main import "fmt" var item []int var m = map[int]int{ 100: 1000, } var m2 = make(map[int]int) ...
String Functions: trim, wrap, randAlpha, plural, etc.String List Functions: splitList, sortAlpha, etc.Math Functions: add, max, mul, etc.Integer Slice Functions: until, untilStepDate Functions: now, date, etc.Defaults Functions: default, empty, coalesce, toJson, toPrettyJson, toRawJson, ...
ColumnType string `gorm:"column_type"` // column_type } // dataSource = fmt.Sprintf("host=%s port=%s user=%s dbname=%s sslmode=%s password=%s","localhost", "5432", "postgres", "test", "disable", "123") func FindTables(dataSource string) []Table { ...