<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Errors on Tony Bai</title><link>https://tonybai.com/tags/errors/</link><description>Recent content in Errors on Tony Bai</description><generator>Hugo</generator><language>zh-cn</language><copyright>2004-2026 Tony Bai. 版权所有.</copyright><lastBuildDate>Sat, 23 Aug 2025 00:00:00 +0800</lastBuildDate><atom:link href="https://tonybai.com/tags/errors/index.xml" rel="self" type="application/rss+xml"/><item><title>泛型重塑 Go 错误检查：errors.As 的下一站 AsA？</title><link>https://tonybai.com/2025/08/23/proposal-errors-asa/</link><pubDate>Sat, 23 Aug 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/08/23/proposal-errors-asa/</guid><description>本文永久链接 – https://tonybai.com/2025/08/23/proposal-errors-asa 大家好，我是Tony Bai。 自 Go 1.13 引入 errors.Is 和 errors.As 以来，Go 语言的错误处理进入了一个结构化、可追溯的新时代。然而，errors.As 的使用方式，对于追求代码简洁与优雅的 Gopher 而言，始终存在一丝“不和谐”：开发者必须...</description></item><item><title>slog 如何同时输出到控制台和文件？MultiHandler 提案或将终结重复造轮子</title><link>https://tonybai.com/2025/07/29/slog-multihandler/</link><pubDate>Tue, 29 Jul 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/07/29/slog-multihandler/</guid><description>本文永久链接 – https://tonybai.com/2025/07/29/slog-multihandler 大家好，我是Tony Bai。 自 log/slog 在 Go 1.21 中引入以来，一个常见的需求始终困扰着开发者：如何将日志同时发送到多个目的地，并为每个目的地设置不同的日志级别？尽管社区已涌现出 samber/slog-multi 等优秀的三方库，但关于“标准库是否应原生支持”...</description></item><item><title>Go errors.Join：是“天赐之物”还是“潘多拉魔盒”？——深入错误聚合的适用场景与最佳实践</title><link>https://tonybai.com/2025/06/20/about-errors-join/</link><pubDate>Fri, 20 Jun 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/06/20/about-errors-join/</guid><description>本文永久链接 – https://tonybai.com/2025/06/20/about-errors-join 大家好，我是Tony Bai。 错误处理，无疑是软件开发中永恒的核心议题之一。Go 语言以其独特的、显式的错误处理机制（即 error 作为普通值返回）而著称，这种设计强调了对错误的关注和及时处理。自 Go 1.13 引入错误包装 (wrapping) 机制以来，Go 的错误处理能力...</description></item><item><title>Go 错误处理语法之争尘埃落定？Go 团队为何十五年探索后仍选择“不”</title><link>https://tonybai.com/2025/06/04/error-syntax/</link><pubDate>Wed, 04 Jun 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/06/04/error-syntax/</guid><description>Go 错误处理语法之争尘埃落定？Go 团队为何十五年探索后仍选择“不” - Tony Bai =============== Tony Bai 一个程序员的心路历程 * Google Go语言编码风格规范 * Google Go语言编码风格规范：指南篇 * Google Go语言编码风格规范：决定篇 * Google Go语言编码风格规范：最佳实践篇 * Go语言第一课FAQ * Go语言进阶课F...</description></item><item><title>云原生时代，如何用RED三板斧搞定服务监控？</title><link>https://tonybai.com/2025/05/26/monitor-design-with-red/</link><pubDate>Mon, 26 May 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/05/26/monitor-design-with-red/</guid><description>云原生时代，如何用RED三板斧搞定服务监控？ - Tony Bai =============== Tony Bai 一个程序员的心路历程 * Google Go语言编码风格规范 * Google Go语言编码风格规范：指南篇 * Google Go语言编码风格规范：决定篇 * Google Go语言编码风格规范：最佳实践篇 * Go语言第一课FAQ * Go语言进阶课FAQ * 关于我 * 文章...</description></item><item><title>“错误即值”，不同实现：Go与Zig错误处理哲学对比</title><link>https://tonybai.com/2025/04/30/go-vs-zig-in-error-handling/</link><pubDate>Wed, 30 Apr 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/04/30/go-vs-zig-in-error-handling/</guid><description>本文永久链接 – https://tonybai.com/2025/04/30/go-vs-zig-in-error-handling 大家好，我是Tony Bai。 使用Go语言有些年头的开发者，大多对其错误处理机制有着复杂的情感。一方面，我们认同 Rob Pike 所倡导的“错误即值 (Errors are values)”的核心哲学——错误不是需要特殊通道（如异常）处理的“二等公民”，它们是...</description></item><item><title>Go错误处理：错误链使用指南</title><link>https://tonybai.com/2023/05/14/a-guide-of-using-go-error-chain/</link><pubDate>Sun, 14 May 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/05/14/a-guide-of-using-go-error-chain/</guid><description>本文永久链接 – https://tonybai.com/2023/05/14/a-guide-of-using-go-error-chain 0\. Go错误处理简要回顾 -------------- Go是一种非常强调错误处理的编程语言。在Go中，错误被表示为实现了error接口的类型的值，error接口只有一个方法： type error interface { Error() string...</description></item><item><title>Go开发命令行程序指南</title><link>https://tonybai.com/2023/03/25/the-guide-of-developing-cli-program-in-go/</link><pubDate>Sat, 25 Mar 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/03/25/the-guide-of-developing-cli-program-in-go/</guid><description>&amp;gt; 注：上面篇首配图的底图由百度文心一格生成。 本文永久链接 – https://tonybai.com/2023/03/25/the-guide-of-developing-cli-program-in-go 近期在Twitter上看到一个名为“Command Line Interface Guidelines”的站点，这个站点汇聚了帮助大家编写出更好命令行程序的哲学与指南。这份指南基于传统的U...</description></item><item><title>Go 1.13中的错误处理</title><link>https://tonybai.com/2019/10/18/errors-handling-in-go-1-13/</link><pubDate>Fri, 18 Oct 2019 00:00:00 +0800</pubDate><guid>https://tonybai.com/2019/10/18/errors-handling-in-go-1-13/</guid><description>介绍 -- 在过去的十年中， Go的errors are values的理念在编码实践中运行得也很良好。尽管标准库对错误处理的的支持很少（只有errors.New和fmt.Errorf函数可以用来构造仅包含字符串消息的错误），但是内置的error接口使Go程序员可以添加所需的任何信息。它所需要的只是一个实现Error方法的类型： type QueryError struct { Query str...</description></item></channel></rss>