会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
眼镜儿
博客园
首页
新随笔
联系
订阅
管理
2020年3月25日
go 读写csv文件
摘要: 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 眼镜儿
阅读(3706)
评论(0)
推荐(0)
2020年3月24日
go sort排序
摘要: 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 眼镜儿
阅读(1015)
评论(0)
推荐(0)
go 生成雪花id
摘要: 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 眼镜儿
阅读(567)
评论(0)
推荐(0)
雪花Id
摘要: 全局唯一Id:雪花算法 雪花算法-snowflake 分布式系统中,有一些需要使用全局唯一ID的场景,这种时候为了防止ID冲突可以使用36位的UUID,但是UUID有一些缺点,首先他相对比较长,另外UUID一般是无序的。 有些时候我们希望能使用一种简单一些的ID,并且希望ID能够按照时间有序生成。
阅读全文
posted @ 2020-03-24 15:13 眼镜儿
阅读(1719)
评论(0)
推荐(0)
time实现定时器
摘要: 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 眼镜儿
阅读(347)
评论(0)
推荐(0)
2020年3月22日
go 生成随机数和键盘输入
摘要:
阅读全文
posted @ 2020-03-22 13:58 眼镜儿
阅读(188)
评论(0)
推荐(0)
go 正则表达式
摘要: 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 眼镜儿
阅读(325)
评论(0)
推荐(0)
2020年3月20日
go 发送邮件
摘要: 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 眼镜儿
阅读(292)
评论(0)
推荐(0)
beego 定时任务
摘要: 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 眼镜儿
阅读(1669)
评论(0)
推荐(0)
2020年3月18日
go 字符串操作
摘要: 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 眼镜儿
阅读(183)
评论(0)
推荐(0)
下一页
公告