§ 路径 / Go
Go → Python
Go 开发者的迁移最顺畅:显式错误处理对应异常,struct 对应 dataclass,隐式接口对应 Protocol。分歧点在并发模型与 GIL。
4 张卡 · 约 50 分钟 · 示例均可在浏览器内运行
01从 go 工具链到 Python 工具链go mod → uv,gofmt → ruff format,go run → uv run。10 分钟02从 if err != nil 到 try/except异常是 Python 的主流错误通道。panic/recover 对应 raise/except 顶层兜底,%w 包装对应 raise from。12 分钟03struct + 方法 → class + dataclass接收者变成 self,组合保留,隐式接口变成 Protocol —— Go 开发者共鸣感最强的一课。12 分钟04从 goroutine 到 asyncio / 线程goroutine+channel ↔ asyncio+Queue。GIL 让线程不是你以为的线程,CPU 密集请用 multiprocessing。15 分钟