对 Go 语言的诚实评价
An Honest Review of Go (2025)

原始链接: https://benraz.dev/blog/golang_review.html

## Go:初步印象与保留 使用Go几个月后,我正在考虑回归Rust,并想概述我的经验。我发现Go的**并发**模型——利用goroutine和channel——集成得非常好且有效,避免了常见的陷阱。**类型系统**虽然简单,但具有灵活性,**结构体嵌入**提供了一种独特的代码重用形式,并且隐式接口满足简化了代码。我也欣赏Go简洁的**语法**,用于可见性和类型注释。 然而,有几个方面让我感到不足。缺乏专用的**枚举**类型,迫使人们使用常量进行笨拙的变通,缺乏类型安全性和穷尽性检查。**不可变性**处理得很差;真正的编译时常量过于严格,促使开发人员转向可变变量和笨拙的函数包装器。 最后,Go的**错误处理**虽然惯用,但依赖于裸的`error`接口。这缺乏信息,迫使字符串解析以获取错误细节,并阻碍了与具有更丰富的错误类型(如Rust的枚举和总和类型)的语言相比的健壮错误处理。缺乏元组进一步限制了错误处理的灵活性。

相关文章

原文

NOTE:

I have written a few small projects in Go, so don’t assume what I am writing is expert opinion on Go. These are just my first thoughts from using the language.

For the past few months, I have been writing Go. I am now considering returning to Rust, but I first want to write what I do and don’t like about Go.

Things I like

Concurrency

Unlike most other languages, concurrency is not an afterthought in Go. Channels and Goroutines are built right into the language as first class features and are mostly a joy to work with in my experience. Go manages to avoid the famous problem of colored functions that plague a lot of other languages’ concurrency models. Additionally, Channels and select statements are in general really nice to use. It’s really hard to get concurrency right and the fact that Go has mostly Gotten concurrency right is very impressive.

Type System

Go’s type system is intentionally very simple and does not allow for complex inheritance trees. While Go does have struct embedding:

All content is licensed under the MIT license unless otherwise posted. (Ben Raz 2024)
联系我们 contact @ memedata.com