<?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>Function on Tony Bai</title><link>https://tonybai.com/tags/function/</link><description>Recent content in Function on Tony Bai</description><generator>Hugo</generator><language>zh-cn</language><copyright>2004-2026 Tony Bai. 版权所有.</copyright><lastBuildDate>Fri, 16 Jan 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://tonybai.com/tags/function/index.xml" rel="self" type="application/rss+xml"/><item><title>为什么 Go 社区强调避免不必要的抽象？—— 借用海德格尔哲学寻找“正确”的答案</title><link>https://tonybai.com/2026/01/16/go-community-the-right-kind-of-abstraction/</link><pubDate>Fri, 16 Jan 2026 00:00:00 +0800</pubDate><guid>https://tonybai.com/2026/01/16/go-community-the-right-kind-of-abstraction/</guid><description>本文永久链接 – https://tonybai.com/2026/01/16/go-community-the-right-kind-of-abstraction 大家好，我是Tony Bai。 **“Go 的哲学强调避免不必要的抽象。”** 这句话我们听过无数次。当你试图引入 ORM、泛型 Map/Reduce 、接口或者复杂的设计模式时，往往会收到这样的反馈。这句话本身没有错，但难点在于：*...</description></item><item><title>Go的简洁性之辩：轻量级匿名函数提案为何七年悬而未决？</title><link>https://tonybai.com/2025/06/03/lightweight-anonymous-func-syntax/</link><pubDate>Tue, 03 Jun 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/06/03/lightweight-anonymous-func-syntax/</guid><description>Go的简洁性之辩：轻量级匿名函数提案为何七年悬而未决？ - Tony Bai =============== Tony Bai 一个程序员的心路历程 * Google Go语言编码风格规范 * Google Go语言编码风格规范：指南篇 * Google Go语言编码风格规范：决定篇 * Google Go语言编码风格规范：最佳实践篇 * Go语言第一课FAQ * Go语言进阶课FAQ * 关于我...</description></item><item><title>Go方法名的作用域：包级，但需间接调用</title><link>https://tonybai.com/2025/03/24/understand-methodname-scope/</link><pubDate>Mon, 24 Mar 2025 00:00:00 +0800</pubDate><guid>https://tonybai.com/2025/03/24/understand-methodname-scope/</guid><description>Go方法名的作用域：包级，但需间接调用 - Tony Bai =============== Tony Bai 一个程序员的心路历程 * Google Go语言编码风格规范 * Google Go语言编码风格规范：指南篇 * Google Go语言编码风格规范：决定篇 * Google Go语言编码风格规范：最佳实践篇 * Go语言第一课FAQ * Go语言进阶课FAQ * 关于我 * 文章列表 ...</description></item><item><title>重拾精髓：go doc -http让离线包文档浏览更便捷</title><link>https://tonybai.com/2024/09/06/go-doc-add-http-support/</link><pubDate>Fri, 06 Sep 2024 00:00:00 +0800</pubDate><guid>https://tonybai.com/2024/09/06/go-doc-add-http-support/</guid><description>重拾精髓：go doc -http让离线包文档浏览更便捷 | Tony Bai =============== Tony Bai一个程序员的心路历程 * Google Go语言编码风格规范 * Google Go语言编码风格规范：指南篇 * Google Go语言编码风格规范：决定篇 * Google Go语言编码风格规范：最佳实践篇 * Go语言第一课FAQ * 关于我 * 文章列表 重拾精髓：...</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/06/04/reflection-programming-guide-in-go/</link><pubDate>Sun, 04 Jun 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/06/04/reflection-programming-guide-in-go/</guid><description>本文永久链接 – https://tonybai.com/2023/06/04/reflection-programming-guide-in-go 反射是一种编程语言的高级特性，它允许程序在运行时检视自身的结构和行为。通过反射，程序可以动态地获取类型(type)与值(value)等信息，并对它们进行操作，诸如修改字段、调用方法等，这使得程序具有更大的灵活性和可扩展性。 不过，反射虽然具有强大的功...</description></item><item><title>聊聊Go语言的控制语句</title><link>https://tonybai.com/2023/05/27/control-flow-statement-in-go/</link><pubDate>Sat, 27 May 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/05/27/control-flow-statement-in-go/</guid><description>本文永久链接 – https://tonybai.com/2023/05/27/control-flow-statement-in-go 在高级编程语言中，控制流语句(control-flow statement)是一类用于控制程序执行流程的语句，以下简称为**控制语句**。它们可以根据条件或循环执行相应的代码块，或者跳转到指定位置执行代码。 常见的控制语句包括： * 条件语句：根据条件执行不同的...</description></item><item><title>理解unsafe-assume-no-moving-gc包</title><link>https://tonybai.com/2023/04/16/understanding-unsafe-assume-no-moving-gc/</link><pubDate>Sun, 16 Apr 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/04/16/understanding-unsafe-assume-no-moving-gc/</guid><description>本文永久链接 – https://tonybai.com/2023/04/16/understanding-unsafe-assume-no-moving-gc 1\. 背景 ------ 在之前的《Go与神经网络：张量计算》一文中，不知道大家是否发现了，所有例子代码执行时，前面都加了一个环境变量ASSUME\_NO\_MOVING\_GC\_UNSAFE\_RISK\_IT\_WITH，就像下面...</description></item><item><title>Go类型系统：有何与众不同</title><link>https://tonybai.com/2022/12/18/go-type-system/</link><pubDate>Sun, 18 Dec 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/12/18/go-type-system/</guid><description>本文永久链接 – https://tonybai.com/2022/12/18/go-type-system Go是一门强类型的静态编程语言。使用Go编程，我们的每一行代码几乎都离不开**类型**。因此，深入学习Go，我们首先要对Go的类型系统(type system)有一个全面和深入的认知。Go类型系统可以给予我们一个全局整体的视角，以帮助我们更好地学习和理解Go语言中那些具体的与类型相关的内容...</description></item><item><title>当函数设计遇到切片</title><link>https://tonybai.com/2022/10/27/when-encountering-slice-during-function-design/</link><pubDate>Thu, 27 Oct 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/10/27/when-encountering-slice-during-function-design/</guid><description>本文永久链接 – https://tonybai.com/2022/10/27/when-encountering-slice-during-function-design 切片(slice)是Go语言中的一种重要的也是最常用的同构数据类型。在Go语言编码过程中，我们多数情况下会使用slice替代数组，一来是因为其动态可扩展，二来在多数场合传递slice的开销要比传递数组要小(这里有一些例外)。 ...</description></item><item><title>GoCN社区Go读书会第二期：《Go语言精进之路》</title><link>https://tonybai.com/2022/07/07/gocn-community-go-book-club-issue2-go-programming-from-beginner-to-master/</link><pubDate>Thu, 07 Jul 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/07/07/gocn-community-go-book-club-issue2-go-programming-from-beginner-to-master/</guid><description>本文永久链接 – https://tonybai.com/2022/07/07/gocn-community-go-book-club-issue2-go-programming-from-beginner-to-master 本文是2022年6月26日我在**GoCN社区的Go读书会第二期《Go语言精进之路》直播的文字稿**。本文对直播的内容做了重新整理与修订，供喜欢阅读文字的朋友们在收看直播后...</description></item><item><title>Go 1.19新特性前瞻</title><link>https://tonybai.com/2022/06/12/go-1-19-foresight/</link><pubDate>Sun, 12 Jun 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/06/12/go-1-19-foresight/</guid><description>本文永久链接 – https://tonybai.com/2022/06/12/go-1-19-foresight 美国时间2022年5月7日，Go 1.19版本开发分支进入新特性冻结(freeze)阶段，即只能修Bug，不能再向Go 1.19版本中增加新特性了。由于上一个版本Go 1.18因引入泛型改动较大，推迟了一个月发布，这直接导致了Go 1.19版本的开发周期被缩短。 虽然开发周期少了近一...</description></item><item><title>绞尽脑汁，帮你理解方法本质并选择正确的receiver类型</title><link>https://tonybai.com/2022/05/17/understand-the-nature-of-go-method-and-how-to-choose-the-correct-receiver-type/</link><pubDate>Tue, 17 May 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/05/17/understand-the-nature-of-go-method-and-how-to-choose-the-correct-receiver-type/</guid><description>本文永久链接 – https://tonybai.com/2022/05/17/understand-the-nature-of-go-method-and-how-to-choose-the-correct-receiver-type Go语言虽然不支持经典的面向对象语法元素，比如：类、对象、继承等，但Go语言也有方法（method）。和函数相比，Go语言中的方法在声明形式上仅仅多了一个参数，G...</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><item><title>一文告诉你神奇的Go内建函数源码在哪里</title><link>https://tonybai.com/2020/12/17/where-is-the-source-of-builtin-functions/</link><pubDate>Thu, 17 Dec 2020 00:00:00 +0800</pubDate><guid>https://tonybai.com/2020/12/17/where-is-the-source-of-builtin-functions/</guid><description>&amp;gt; Go内建函数源码，我好像在哪里见过你。 – 佚名 1\. 何为Go内建函数 众所周知，Go是最简单的主流编程语言之一，截至Go 1.15版本，Go语言的关键字的规模依旧保持在25个： 很多刚入门的gopher可能会问：像bool、byte、error、true、iota甚至int都难道都不是关键字？没错！和其他语言不同，这些**标识符**并不是关键字，在Go中它们被称为**预定义标识符**。这...</description></item><item><title>Go函数调用链跟踪的一种实现思路</title><link>https://tonybai.com/2020/12/10/a-kind-of-thinking-about-how-to-trace-function-call-chain/</link><pubDate>Thu, 10 Dec 2020 00:00:00 +0800</pubDate><guid>https://tonybai.com/2020/12/10/a-kind-of-thinking-about-how-to-trace-function-call-chain/</guid><description>这篇文章的初衷是想解答知乎上的一位知友提出的问题。没想到完成一种实现后，这个问题居然被删除了。那么既然实现了，就分享出来吧。问题的原文找不到了，问题大致是这样的： 一个程序中存在多个函数调用链都调用了函数D： A1 -&amp;gt; B1 &amp;gt; C1 -&amp;gt; D A2 -&amp;gt; B2 &amp;gt; C2 -&amp;gt; D A3 -&amp;gt; B3 -&amp;gt; C3 -&amp;gt; D ... ... 那么，如果某次函数D被调用时出现了问题，那么怎么知道这个D...</description></item><item><title>defer函数参数求值简要分析</title><link>https://tonybai.com/2018/03/23/the-analysis-of-the-param-evaluation-of-defer-functions/</link><pubDate>Fri, 23 Mar 2018 00:00:00 +0800</pubDate><guid>https://tonybai.com/2018/03/23/the-analysis-of-the-param-evaluation-of-defer-functions/</guid><description>一. 引子 书接上文，在发表了《对一段Go语言代码输出结果的简要分析》一文之后，原问题提出者又有了新问题，这是一个典型Gopher学习Go的历程，想必很多Gopher们，包括我自己都遇到过的。我们先来看看这段代码(来自原问题提出者)： // https://play.golang.org/p/dOUFNj96EIQ package main import &amp;#34;fmt&amp;#34; func main() { v...</description></item><item><title>对一段Go语言代码输出结果的简要分析</title><link>https://tonybai.com/2018/03/20/the-analysis-of-output-results-of-a-go-code-snippet/</link><pubDate>Tue, 20 Mar 2018 00:00:00 +0800</pubDate><guid>https://tonybai.com/2018/03/20/the-analysis-of-output-results-of-a-go-code-snippet/</guid><description>年后事情实在是多，各种被催进度，于是好长一段时间未更博客了，自责中….。今天蹦出来热热身^0^！ 中午在微博私信中看到一封来自某Gopher的咨询，他贴了一段代码，并表示对代码的输出结果的不解，希望我能帮他分析一下。他的代码如下： //testslicerange.go package main import ( &amp;#34;fmt&amp;#34; &amp;#34;time&amp;#34; ) type field struct { name st...</description></item><item><title>经典设计原则背后的本质</title><link>https://tonybai.com/2010/09/17/the-nature-of-some-classical-design-rules/</link><pubDate>Fri, 17 Sep 2010 00:00:00 +0800</pubDate><guid>https://tonybai.com/2010/09/17/the-nature-of-some-classical-design-rules/</guid><description>近一段时间重读了一些经典书籍，诸如《敏捷软件开发：原则、模式与实践》、 《程序员修炼之道》、《Unix编程艺术》等。这些书中关于如何衡量或评价一个类或函数设计好坏的几个原则(Principle)让人印象深刻。《敏捷软件开发》中谈到了SRP、OCP、DIP; 程序员修炼之道则以DRY、“正交性”为话题展开;《Unix编程艺术》围绕紧凑性、SPOT、分离等阐述作者立场。这么多经典原则，如何学习把握？我...</description></item><item><title>一次函数设计讨论</title><link>https://tonybai.com/2010/09/02/an-discussion-on-function-design/</link><pubDate>Thu, 02 Sep 2010 00:00:00 +0800</pubDate><guid>https://tonybai.com/2010/09/02/an-discussion-on-function-design/</guid><description>近期在考虑对底层函数库进行一些重构，今天下午花了两个小时考量现有的函数库的接口设计，发现目前函数库的实现存在着一个普遍的问题：与特定的内存分配实现耦合的太紧。 我们的应用是多进程结构的，并使用了共享内存这种最快捷的IPC机制，鉴于此很多同事在实现一些数据结构或者算法时可能只考虑到了我们常见的应用场景-多进程共享，而对非共享内存分配的情况考虑不足。那如何将目前某些库函数实现与内存分配之间的强耦合解开...</description></item></channel></rss>