<?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>Errorf on Tony Bai</title><link>https://tonybai.com/tags/errorf/</link><description>Recent content in Errorf on Tony Bai</description><generator>Hugo</generator><language>zh-cn</language><copyright>2004-2026 Tony Bai. 版权所有.</copyright><lastBuildDate>Fri, 27 Jun 2025 00:00:00 +0800</lastBuildDate><atom:link href="https://tonybai.com/tags/errorf/index.xml" rel="self" type="application/rss+xml"/><item><title>Gopher视角：Java 开发者转向 Go 时，最需要“掰过来”的几个习惯</title><link>https://tonybai.com/2025/06/27/from-java-to-go/</link><pubDate>Fri, 27 Jun 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/06/27/from-java-to-go/</guid><description>Gopher视角：Java 开发者转向 Go 时，最需要“掰过来”的几个习惯 - Tony Bai =============== Tony Bai 一个程序员的心路历程 * Google Go语言编码风格规范 * Google Go语言编码风格规范：指南篇 * Google Go语言编码风格规范：决定篇 * Google Go语言编码风格规范：最佳实践篇 * Go语言第一课FAQ * Go语言进...</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>要么返回错误值，要么输出日志，别两样都做</title><link>https://tonybai.com/2024/04/14/either-return-error-or-log-them-do-not-do-both/</link><pubDate>Sun, 14 Apr 2024 00:00:00 +0800</pubDate><guid>https://tonybai.com/2024/04/14/either-return-error-or-log-them-do-not-do-both/</guid><description>本文永久链接 – https://tonybai.com/2024/04/14/either-return-error-or-log-them-do-not-do-both 1\. 缘起 ------ 这周，一个产品团队内进行Go代码评审时，得到了一个结论：所有的if err != nil的地方都应该输出错误日志。然而，这种做法并不是最佳实践，它存在一些问题。 首先，打印过多的错误日志会导致日志文...</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 1.13中值得关注的几个变化</title><link>https://tonybai.com/2019/10/27/some-changes-in-go-1-13/</link><pubDate>Sun, 27 Oct 2019 00:00:00 +0800</pubDate><guid>https://tonybai.com/2019/10/27/some-changes-in-go-1-13/</guid><description>2019年对于Go语言来说也是一个重要的年份，因为在2019年的11月10日，Go即将迎来其开源10周年的纪念日。在这个重要日子的前夕，在GopherCon 2019大会后，Go项目组在2019.9.4日发布了Go 1.13版本。 这是自2017年GopherCon大会上Russ Cox做“Toward Go 2″主题演讲以来Go项目发布的第四个版本（前三个分别是：go 1.10、go 1.11和...</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>