包含标签 Go 的文章

Go实现不同goroutine之间的阻塞

Go 程序从 main 包的 main() 函数开始,在程序启动时,Go 程序就会为 main() 函数创建一个默认的 goroutine。 所有 goroutine 在 main() 函数结束时会一同结束。 若在启用的goroutine中不使用WaitGroup的话会因为main函数已执行完,阻塞的函数与发送信号的函数会一同结束,不能真正实现阻塞的功能。 因此可……

阅读全文

Go的继承与重写以及结构体嵌套

1. 首先声明两个基础结构体(其他语言的基类吧:)) 1 2 3 4 5 6 7 type Animal struct { Name string } type Old struct { Age int } 并给Animal类增加一个方法Walk() 1 2 3 func (a *Animal) Walk() { fmt.Println("Animal Walk") } 2. 让People类嵌套(继承)上面的Animal和Old类 这时可以有两种匿名嵌套(继承)方式 嵌套结构体指针 嵌套结构体 1 2 3 4 5……

阅读全文

Usehugo

如何使用hugo 新建文章 1 2 3 hugo new posts/xxx.md 发布 1 hugo -d /target/dir……

阅读全文