<?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>Closure on Tony Bai</title><link>https://tonybai.com/tags/closure/</link><description>Recent content in Closure on Tony Bai</description><generator>Hugo</generator><language>zh-cn</language><copyright>2004-2026 Tony Bai. 版权所有.</copyright><lastBuildDate>Tue, 02 Jun 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://tonybai.com/tags/closure/index.xml" rel="self" type="application/rss+xml"/><item><title>再见样板代码！Go 官方新提案：函数一键转接口</title><link>https://tonybai.com/2026/06/02/no-more-boilerplate-go-proposal-function-to-interface-conversion/</link><pubDate>Tue, 02 Jun 2026 00:00:00 +0800</pubDate><guid>https://tonybai.com/2026/06/02/no-more-boilerplate-go-proposal-function-to-interface-conversion/</guid><description>本文永久链接 – https://tonybai.com/2026/06/02/no-more-boilerplate-go-proposal-function-to-interface-conversion 大家好，我是Tony Bai。 在 Go 语言日常开发中，有一个设计几乎人人写过，但写多了又让人觉得极其繁琐、甚至有些“脱裤子放屁”的样板代码。 假设你需要一个只读数据的 io.Reader...</description></item><item><title>Robert Griesemer 亲述：只解决 90% 问题的“箭头函数”该长什么样？</title><link>https://tonybai.com/2026/05/06/robert-griesemer-on-go-arrow-functions/</link><pubDate>Wed, 06 May 2026 00:00:00 +0800</pubDate><guid>https://tonybai.com/2026/05/06/robert-griesemer-on-go-arrow-functions/</guid><description>本文永久链接 – https://tonybai.com/2026/05/06/robert-griesemer-on-go-arrow-functions 大家好，我是Tony Bai。 在 Go 语言的演进史上，很少有一个 Issue 能像 #21498 这样，跨越 9 年时光，累积近千条评论，却依然让官方核心团队如履薄冰。 这个 Issue 的目标很单纯：**为 Go 提供一种更简洁的匿名函...</description></item><item><title>再见，丑陋的 container/heap！Go 泛型堆 heap/v2 提案解析</title><link>https://tonybai.com/2026/02/04/goodbye-container-heap-go-generic-heap-heap-v2-proposal/</link><pubDate>Wed, 04 Feb 2026 00:00:00 +0800</pubDate><guid>https://tonybai.com/2026/02/04/goodbye-container-heap-go-generic-heap-heap-v2-proposal/</guid><description>本文永久链接 – https://tonybai.com/2026/02/04/goodbye-container-heap-go-generic-heap-heap-v2-proposal 大家好，我是Tony Bai。 每一个写过 Go 的开发者，大概都经历过被 container/heap 支配的恐惧。 你需要定义一个切片类型，实现那个包含 5 个方法的 heap.Interface，在 P...</description></item><item><title>内存去哪儿了？一个让大多数 Gopher 都无法清晰回答的问题</title><link>https://tonybai.com/2026/01/15/where-did-the-memory-go-gopher-unanswered-question/</link><pubDate>Thu, 15 Jan 2026 00:00:00 +0800</pubDate><guid>https://tonybai.com/2026/01/15/where-did-the-memory-go-gopher-unanswered-question/</guid><description>本文永久链接 – https://tonybai.com/2026/01/15/where-did-the-memory-go-gopher-unanswered-question 大家好，我是Tony Bai。 &amp;gt; “我的服务内存又在缓慢增长了，pprof 显示不出明显的泄漏点……**内存到底去哪儿了？**” 这句午夜梦回的拷问，或许是许多 Go 开发者心中最深的恐惧。 这一切的根源，可能始于一...</description></item><item><title>“这代码迟早出事！”——复盘线上问题：六个让你头痛的Go编码坏味道</title><link>https://tonybai.com/2025/05/31/six-smells-in-go/</link><pubDate>Sat, 31 May 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/05/31/six-smells-in-go/</guid><description>本文永久链接 – https://tonybai.com/2025/05/31/six-smells-in-go 大家好，我是Tony Bai。 在日常的代码审查 (Code Review) 和线上问题复盘中，我经常会遇到一些看似不起眼，却可能埋下巨大隐患的 Go 代码问题。这些“编码坏味道”轻则导致逻辑混乱、性能下降，重则引发数据不一致、系统崩溃，甚至让团队成员在深夜被告警声惊醒，苦不堪言。 今...</description></item><item><title>通过Go示例理解函数式编程思维</title><link>https://tonybai.com/2024/08/11/understand-functional-programming-in-go/</link><pubDate>Sun, 11 Aug 2024 00:00:00 +0800</pubDate><guid>https://tonybai.com/2024/08/11/understand-functional-programming-in-go/</guid><description>本文永久链接 – https://tonybai.com/2024/08/11/understand-functional-programming-in-go &amp;gt; 一个孩子要尝试10次、20次才肯接受一种新的食物，我们接受一种新的范式，大概不会比这个简单。– 郭晓刚 《函数式编程思维》译者 函数式编程(Functional Programming, 简称fp)是一种编程范式，与命令式编程(Impe...</description></item><item><title>十分钟入门Go语言</title><link>https://tonybai.com/2023/02/23/learn-go-in-10-min/</link><pubDate>Thu, 23 Feb 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/02/23/learn-go-in-10-min/</guid><description>本文永久链接 – https://tonybai.com/2023/02/23/learn-go-in-10-min 本文旨在带大家快速入门Go语言，期望小伙伴们在花费十分钟左右通读全文后能对Go语言有一个初步的认知，为后续进一步深入学习Go奠定基础。 本文假设你完全没有接触过Go，你可能是一名精通其他编程语言的程序员，也可能是毫无编程经验、刚刚想转行为码农的热血青年。 编程简介 ---- 编程就...</description></item><item><title>Go语言数据竞争检测与数据竞争模式</title><link>https://tonybai.com/2022/06/21/data-race-detection-and-pattern-in-go/</link><pubDate>Tue, 21 Jun 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/06/21/data-race-detection-and-pattern-in-go/</guid><description>本文永久链接 – https://tonybai.com/2022/06/21/data-race-detection-and-pattern-in-go uber，就是那个早早退出中国打车市场的优步，是Go语言早期接纳者，也是Go技术栈的“重度用户”。uber内部的Go代码仓库有5000w+行Go代码，有2100个Go实现的独立服务，这样的Go应用规模在世界范围内估计也是Top3了吧。 uber...</description></item><item><title>Go 1.17新特性详解：使用基于寄存器的调用惯例</title><link>https://tonybai.com/2021/08/20/using-register-based-calling-convention-in-go-1-17/</link><pubDate>Fri, 20 Aug 2021 00:00:00 +0800</pubDate><guid>https://tonybai.com/2021/08/20/using-register-based-calling-convention-in-go-1-17/</guid><description>本文永久链接 – https://tonybai.com/2021/08/20/using-register-based-calling-convention-in-go-1-17 除了Go语言特性与go module有重要变化之外，Go编译器与Go运行时也都有着优化与改进，这两方面的变化对Go程序的构建与运行影响巨大。在这个系列的最后一篇中，我们来看看编译器与运行时中那些值得关注的变化。 1. ...</description></item><item><title>Go 1.17中值得关注的几个变化</title><link>https://tonybai.com/2021/08/17/some-changes-in-go-1-17/</link><pubDate>Tue, 17 Aug 2021 00:00:00 +0800</pubDate><guid>https://tonybai.com/2021/08/17/some-changes-in-go-1-17/</guid><description>本文永久链接 – https://tonybai.com/2021/08/17/some-changes-in-go-1-17 Go核心开发团队在去年GopherCon大会上给Go泛型的定调是在2022年2月份的Go 1.18版本中发布，那可是自Go诞生以来语法规范变动最大的一次，这让包括笔者在内的全世界的Gopher们都满怀期待。 不过别忘了，在Go 1.18这个“网红版本”发布前，还有一个“实...</description></item><item><title>Go中被闭包捕获的变量何时会被回收</title><link>https://tonybai.com/2021/08/09/when-variables-captured-by-closures-are-recycled-in-go/</link><pubDate>Mon, 09 Aug 2021 00:00:00 +0800</pubDate><guid>https://tonybai.com/2021/08/09/when-variables-captured-by-closures-are-recycled-in-go/</guid><description>本文永久链接 – https://tonybai.com/2021/08/09/when-variables-captured-by-closures-are-recycled-in-go 1. Go函数闭包 Go语言原生提供了对闭包(closure)的支持。在Go语言中，闭包就是函数字面值。Go规范中是这样诠释闭包的： &amp;gt; 函数字面值(function literals)是闭包：它们可以引用其包...</description></item></channel></rss>