摘要: package main import ( "encoding/csv" "fmt" "os" ) func write() { f, err := os.Create("test.csv") if err != nil{ fmt.Println(err) return } defer f.Clos 阅读全文
posted @ 2020-03-25 15:41 眼镜儿 阅读(3674) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "sort" ) func main() { str := []string{"我", "是", "d", "b","c", } sort.Strings(str) fmt.Println(str) ints := []int{5,4,3,2, 阅读全文
posted @ 2020-03-24 15:52 眼镜儿 阅读(1004) 评论(0) 推荐(0) 编辑
摘要: package lib import ( "sync" "time" ) type AlgorithmSnowFlake struct { sync.Mutex machineId int64 dataCenterId int64 lastTimeStamp int64 sn int64 } var 阅读全文
posted @ 2020-03-24 15:27 眼镜儿 阅读(506) 评论(0) 推荐(0) 编辑
摘要: 全局唯一Id:雪花算法 雪花算法-snowflake 分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。 有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。 阅读全文
posted @ 2020-03-24 15:13 眼镜儿 阅读(1685) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "time" ) func task() { fmt.Println(time.Now().Local()) } func main() { task() t := time.NewTimer(time.Second * 5) for { se 阅读全文
posted @ 2020-03-24 11:12 眼镜儿 阅读(340) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-03-22 13:58 眼镜儿 阅读(181) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "regexp" ) func main() { str := "abc123456" match, err := regexp.Match("\u4e00", []byte(str)) fmt.Println(match, err) matc 阅读全文
posted @ 2020-03-22 13:35 眼镜儿 阅读(316) 评论(0) 推荐(0) 编辑
摘要: email 模块 func SendMail(i int, err error) { e := email.NewEmail() e.From = "zj <896829948@qq.com>" e.To = []string{"13864264702@163.com"} e.Subject = " 阅读全文
posted @ 2020-03-20 16:28 眼镜儿 阅读(287) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "github.com/astaxie/beego/toolbox" "time" ) func task() error { fmt.Println(time.Now().Format("2006-01-02 15:04:05")) retu 阅读全文
posted @ 2020-03-20 10:11 眼镜儿 阅读(1637) 评论(0) 推荐(0) 编辑
摘要: 1 package main 2 3 import ( 4 "fmt" 5 "strconv" 6 "strings" 7 ) 8 9 // 字符串遍历 10 func bL(str string) { 11 fmt.Println(len(str)) // 字节长度 12 // for range 阅读全文
posted @ 2020-03-18 23:02 眼镜儿 阅读(177) 评论(0) 推荐(0) 编辑