geektutu / blog

极客兔兔的博客,Coding Coding 创建有趣的开源项目。
https://geektutu.com
Apache License 2.0
167 stars 21 forks source link

Go 空结构体 struct{} 的使用 | Go 语言高性能编程 | 极客兔兔 #117

Open geektutu opened 3 years ago

geektutu commented 3 years ago

https://geektutu.com/post/hpg-empty-struct.html

Go 语言/golang 高性能编程,Go 语言进阶教程,Go 语言高性能编程(high performance go)。本文介绍了使用空 struct{}/空结构体的优点:不占用内存,且具有良好的语义。

xiezhenyu19970913 commented 3 years ago

学到了很多细节,感谢!

geektutu commented 3 years ago

@xiezhenyu19970913 笔芯~ 😊

lyf9528 commented 3 years ago

好文

xx444812313 commented 3 years ago

讲得很好,博主很厉害,跟着你学习

heng4719 commented 3 years ago

学到了,写的很棒

gostudying commented 2 years ago

期待更新。

HongkaiJiao commented 2 years ago

👍🏻棒棒哒~💯

018429 commented 2 years ago

感谢,写的非常好👍

ykfish commented 2 years ago

@lanjianvae 期待更新。

大佬,请问你github里关于go面试的资料可以分享一下吗

haima96 commented 2 years ago

2.3没看懂有什么意义呢,或者说存在哪些应用场景呢

EndlessCheng commented 2 years ago

2.3没看懂有什么意义呢,或者说存在哪些应用场景呢

我的理解是用来给一系列方法分组的

haima96 commented 2 years ago

@EndlessCheng

2.3没看懂有什么意义呢,或者说存在哪些应用场景呢

我的理解是用来给一系列方法分组的

啊,十分感谢

dablelv commented 2 years ago

精妙啊

spiritbird commented 2 years ago

讲得很详细,学到了

strawberry2020 commented 2 years ago

这里在worker函数首行执行<-ch,会不会导致<-ch后面的代码还未执行main函数就已经退出的情况。

2.3 仅包含方法的结构体 func worker(ch chan struct{}) { <-ch fmt.Println("do something") close(ch) }

func main() { ch := make(chan struct{}) go worker(ch) ch <- struct{}{} }