随笔分类 -  golang相关2009

无缓冲通道 vs 有缓冲通道
摘要:无缓冲通道 vs 有缓冲通道 无缓冲通道,在通道满了之后就会阻塞所在的goroutine。(需要在其他goroutine中取出该通道中的元素,才能解除它所在通道的阻塞,不然就会一直阻塞下去。) 有缓冲通道,存完了东西可以不取出来,不会阻塞。 // 无缓冲通道,阻塞示例 func chanWillLo 阅读全文

posted @ 2021-02-23 14:12 Sweet小马 阅读(106) 评论(0) 推荐(0)

go实现终端输出颜色文本
摘要:go实现终端输出颜色文本 // 示例 fmt.Printf("\033[1;31;40m%s\033[0m\n","高亮显示 - 红色文字,黑色底哒") fmt.Printf("\033[4;31;40m%s\033[0m\n","下划线 - 红色文字,黑色底哒") fmt.Printf("\033 阅读全文

posted @ 2021-02-22 14:50 Sweet小马 阅读(1748) 评论(0) 推荐(0)

JetBrains macOS下快捷键 & 设置-不断完善……
摘要:##JetBrains macOS下快捷键 & 设置-不断完善…… 操作 说明 mac按键 Reformat Code 代码格式化。 ⌥ + ⇧ + F Rename 重命名(字段/文件名)。 ⌘ + R Close Other Tabs 关闭编辑栏中其他文件。 ⌘ + ⇧ + W Move Lin 阅读全文

posted @ 2021-02-13 09:25 Sweet小马 阅读(160) 评论(0) 推荐(0)

go 中 var声明对比
摘要:此处的 config1 是指针类型,零值为nil。 config2 为结构体,零值为各个字段的零值的集合。 config3 同 config2。 阅读全文

posted @ 2021-02-10 21:55 Sweet小马 阅读(65) 评论(0) 推荐(0)

golang中 reflect 反射属性和方法
摘要:golang中 reflect 反射属性和方法 type Person struct { Name string Age int } func (p *Person) SetAge(newAge int) { p.Age = newAge } func (p Person) GetName() st 阅读全文

posted @ 2020-08-03 15:46 Sweet小马 阅读(463) 评论(0) 推荐(0)

golang中读取文件
摘要:读文件 方式1 方式2 缓冲区读取大文件 节选自 "右眼皮的爱 简书" 阅读全文

posted @ 2019-11-14 10:33 Sweet小马 阅读(1478) 评论(0) 推荐(0)

golang指针函数
摘要:func main() { a := models.SmsVerify{} a.Id = 100 fmt.Println(a.Id) // 100 test111(a) fmt.Println(a.Id) // 100 a222 := new(models.SmsVerify) a222.Id = 阅读全文

posted @ 2019-11-06 12:01 Sweet小马 阅读(1129) 评论(0) 推荐(0)

golang中的 time 常用操作
摘要:时间戳时间戳 (例如: 1554714009)time.now().Unix()格式时间 (例如: 2019-04-08 17:00:09)time.Now().Format("2006-01-02 15:04:05")时间戳转时间 (例如: 1554714009 => 2019-04-08 17:00:09)2006-01-02 15:04:05 这几个数字是固定的.time.Unix(1554... 阅读全文

posted @ 2019-04-11 14:58 Sweet小马 阅读(305) 评论(0) 推荐(0)

golang中的接口实现(二)
摘要:指针类型 vs 值类型实现接口 实现多个接口 接口的嵌套 (go 中没有类似 Java,C# 中的父类这种东西, 但是可以通过嵌入其他接口来创建新的接口.) 接口零值 阅读全文

posted @ 2019-04-11 10:23 Sweet小马 阅读(439) 评论(0) 推荐(0)

golang中的接口实现(一)
摘要:golang中的接口实现// 定义一个接口type People interface { getAge() int // 定义抽象方法1 getName() string // 定义抽象方法2}type Man struct {}func (a *Man) getAge() int { // 实现抽象方法1 return 18}func (a *Main) getName() s... 阅读全文

posted @ 2019-04-10 17:54 Sweet小马 阅读(4431) 评论(0) 推荐(0)

导航