最近发布的主题
暂无
最近发布的文章
最近分享的资源
暂无
最近发布的项目
暂无
最近的评论
-
评论了主题 结构体怎么判断为空?Demo code ```go package main import ( "fmt" "reflect" ) type A struct{ name string age int } func (a A) IsEmpty() bool { return reflect.DeepEqual(a, A{}) } func main() { var a A if a == (A{}) { // 括号不能去 fmt.Println("a == A{} empty") } if a.IsEmpty() { fmt.Println("reflect deep is empty") } } ```
-
#5楼 @LichFaker Container是有receive的对象,不是struct的数据结构,lock的scope只在receive内部,不对外有修改逻辑。对Container的Copy行为,应该慎重,不应该有这样的逻辑,直接使用receive对象就可以。把锁的声明修改为指针,一样可以修改指针的值,引发逻辑错误或者panic,这和形式无关。