01 2021 档案
摘要:原文链接:http://www.zhoubotong.site/post/24.html直入正题,我们看下以下代码: package main import ( "encoding/json" "fmt" ) func main() { //第一种声明 var language map[string
阅读全文
摘要:原文链接:http://www.zhoubotong.site/post/23.html 遍历结构体 如何实现遍历结构体字段? 好吧,言归正传!举个例子:demo1: package main import ( "fmt" "reflect" ) type Student struct { name
阅读全文
摘要:原文链接:http://www.zhoubotong.site/post/19.html 大家可能经常会用到类似如下代码片段: package main import ( "fmt" "sync" "time" ) func main() { sli := []int{0, 1, 2, 3, 4,
阅读全文
摘要:原文链接: http://www.zhoubotong.site/post/17.htmlGo的error比较灵活.但是自身对error处理的机制有不太好用,我们可以自定义错误输出: 只要所有实现了 Error() 方法的对象都可以, 这里给个比较简单的demo,后续整理一个error的优化封装:
阅读全文