<?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>常量 on Tony Bai</title><link>https://tonybai.com/tags/%E5%B8%B8%E9%87%8F/</link><description>Recent content in 常量 on Tony Bai</description><generator>Hugo</generator><language>zh-cn</language><copyright>2004-2026 Tony Bai. 版权所有.</copyright><lastBuildDate>Fri, 29 Mar 2024 00:00:00 +0800</lastBuildDate><atom:link href="https://tonybai.com/tags/%E5%B8%B8%E9%87%8F/index.xml" rel="self" type="application/rss+xml"/><item><title>Go 1.22引入的包级变量初始化次序问题</title><link>https://tonybai.com/2024/03/29/the-issue-in-pkg-level-var-init-order-in-go-1-22/</link><pubDate>Fri, 29 Mar 2024 00:00:00 +0800</pubDate><guid>https://tonybai.com/2024/03/29/the-issue-in-pkg-level-var-init-order-in-go-1-22/</guid><description>本文永久链接 – https://tonybai.com/2024/03/29/the-issue-in-pkg-level-var-init-order-in-go-1-22 细心的朋友可能已经注意到，从春节后，我的博客就“停更”了！实际上，这一情况部分是因为工作上的事务繁忙，另一部分则是因为我将工作之外的闲暇时间更多地投入到一本即将于今年中下旬出版的书的撰写了：在之前的积累基础上，我花了两个多...</description></item><item><title>Go 1.21中值得关注的几个变化</title><link>https://tonybai.com/2023/08/20/some-changes-in-go-1-21/</link><pubDate>Sun, 20 Aug 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/08/20/some-changes-in-go-1-21/</guid><description>本文永久链接 – https://tonybai.com/2023/08/20/some-changes-in-go-1-21 美国时间2023年8月8日，Go团队在Go官博上正式发布了1.21版本！ 早在今年4月末，我就撰写了文章《Go 1.21新特性前瞻》，对Go 1.21可能引入的新特性、新优化和新标准库包做了粗略梳理。 在6月初举办的GopherChina 2023大会上，我又以“The ...</description></item><item><title>Go：值与指针</title><link>https://tonybai.com/2023/05/05/go-value-and-pointer/</link><pubDate>Fri, 05 May 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/05/05/go-value-and-pointer/</guid><description>本文永久链接 – https://tonybai.com/2023/05/05/go-value-and-pointer 1\. 计算机中的值 ---------- 在百万年的演化历史中，人类对事物的属性进行了抽象，有了数量、精度、信息等概念的表示，对应的我们称之为整数、小数、文本文字等。计算机出现后，我们使用计算机对真实世界的问题进行建模，通过计算机的高效计算解决这些问题并输出答案。为了建模，计...</description></item><item><title>聊聊Go语言的全局变量</title><link>https://tonybai.com/2023/03/22/global-variable-in-go/</link><pubDate>Wed, 22 Mar 2023 00:00:00 +0800</pubDate><guid>https://tonybai.com/2023/03/22/global-variable-in-go/</guid><description>本文永久链接 – https://tonybai.com/2023/03/22/global-variable-in-go &amp;gt; 注：上面篇首配图的底图由百度文心一格生成。 C语言是Go语言的先祖之一，Go继承了很多C语言的语法与表达方式，这其中就包含了**全局变量**，虽然Go在其语法规范中并没有直接给出全局变量的定义。但是已经入门Go的童鞋都知道，在Go中**包的导出变量(exported va...</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>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>len(s)表达式的求值结果究竟是常量还是变量？我来告诉你</title><link>https://tonybai.com/2022/03/24/the-result-of-a-len-expression-is-constant-or-variable/</link><pubDate>Thu, 24 Mar 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/03/24/the-result-of-a-len-expression-is-constant-or-variable/</guid><description>本文永久链接 – https://tonybai.com/2022/03/24/the-result-of-a-len-expression-is-constant-or-variable **len**是Go预定义标识符，同时也是Go内置的预定义函数，通过go doc工具我们能查到len函数的doc如下： ``` $go doc builtin.len package builtin // im...</description></item><item><title>为什么这个T类型实例无法调用*T类型的方法</title><link>https://tonybai.com/2022/02/27/go-addressable/</link><pubDate>Sun, 27 Feb 2022 00:00:00 +0800</pubDate><guid>https://tonybai.com/2022/02/27/go-addressable/</guid><description>本文永久链接 – https://tonybai.com/2022/02/27/go-addressable 近期在“Go语言第一课”专栏后台看到一位学员的一则留言，如下图： 由于有课程上下文，所以我这里将问题的上下文重新描述一下。 在专栏的第25讲，我们学习了Go语言提供的一个“语法糖”，比如下面这个例子： ``` type T struct { a int } func (t T) M1() ...</description></item><item><title>惊了！原来Go语言也有隐式转型</title><link>https://tonybai.com/2021/12/02/go-has-implicit-type-convertion/</link><pubDate>Thu, 02 Dec 2021 00:00:00 +0800</pubDate><guid>https://tonybai.com/2021/12/02/go-has-implicit-type-convertion/</guid><description>本文永久链接 – https://tonybai.com/2021/12/02/go-has-implicit-type-convertion 我的极客时间专栏《Go语言第一课》上线后收到了很多学员的反馈，大家提出了很多显然是经过认真思考的高水平问题。有些时候我也会被这些问题所“难倒”，比如昨天我在后台看到的这个问题。 我把这个问题整理为下面代码文本，方便大家copy和重现问题： ``` pack...</description></item><item><title>Go语言的“黑暗角落”：盘点学习Go语言时遇到的那些陷阱[译]（第二部分）</title><link>https://tonybai.com/2021/03/29/darker-corners-of-go-part2/</link><pubDate>Mon, 29 Mar 2021 00:00:00 +0800</pubDate><guid>https://tonybai.com/2021/03/29/darker-corners-of-go-part2/</guid><description>本文翻译自Rytis Bieliunas的文章《Darker Corners of Go》。 第一部分参见[《Go语言的“黑暗角落”：盘点学习Go语言时遇到的那些陷阱\[译\]（第一部分）》](https://tonybai.com/2021/03/29/darker-corners-of-go-part1) 7\. 字符串和字节数组 ------------ 1) Go中的字符串 Go字符串的内...</description></item><item><title>Go语言的“黑暗角落”：盘点学习Go语言时遇到的那些陷阱[译]（第一部分）</title><link>https://tonybai.com/2021/03/29/darker-corners-of-go-part1/</link><pubDate>Mon, 29 Mar 2021 00:00:00 +0800</pubDate><guid>https://tonybai.com/2021/03/29/darker-corners-of-go-part1/</guid><description>本文翻译自Rytis Bieliunas的文章《Darker Corners of Go》。 &amp;gt; 译注：若干年前，Kyle Quest曾发过一篇名为“50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs”的文章，仿效著名的《C Traps and Pitfalls》编写了50条Go语言的陷阱与缺陷，一时在G...</description></item><item><title>Go 1.10中值得关注的几个变化</title><link>https://tonybai.com/2018/02/17/some-changes-in-go-1-10/</link><pubDate>Sat, 17 Feb 2018 00:00:00 +0800</pubDate><guid>https://tonybai.com/2018/02/17/some-changes-in-go-1-10/</guid><description>又到了Go语言新版本的发布时间窗口了！这次的主角是Go 1.10。 曾几何时， 这是很多Gopher在Go 1.8、Go 1.9时猜测是否存在的那个版本，毕竟minor version即将进化到两位数。从Go语言第一封设计mail发出到现在的十年间，尤其是Go语言经历了近几年的爆发式增长，基本奠定了云原生第一语言的位置之后，人们对Go语言有了更多新的、更为深刻的认知，同时对这门编程语言也有了更多的...</description></item><item><title>《Understanding and Using C Pointers》要点先睹为快</title><link>https://tonybai.com/2013/05/28/understanding-and-using-c-pointers-keypoint-preview/</link><pubDate>Tue, 28 May 2013 00:00:00 +0800</pubDate><guid>https://tonybai.com/2013/05/28/understanding-and-using-c-pointers-keypoint-preview/</guid><description>_如果你问十个C程序员：你觉得C语言的核心是什么？这十个程序员都会回答：指针。_ 指针具备成为C语言核心的两个关键要素：**强大**与**争议**。 \* **指针的强大**源自于其天生与机器内存模型的适配。使用指针让代码紧凑，并可获得仅次于汇编代码的执行效率；使用指针可以让C程 序员毫不费力地尽情操纵着内存中的每个byte甚至是bit；使用指针可以为C程序员提供无与伦比的操作灵活性。总之，在C语...</description></item><item><title>常量类型的识别-一个小例子</title><link>https://tonybai.com/2008/12/02/an-example-for-recognizing-the-const-variable/</link><pubDate>Tue, 02 Dec 2008 00:00:00 +0800</pubDate><guid>https://tonybai.com/2008/12/02/an-example-for-recognizing-the-const-variable/</guid><description>今天闲时写了一个Demo测试程序，目的：测试64位编译下使用mmap映射共享内存的能力。程序很简单，大致如下结构： #define MAP\_SPACE\_SIZE  (4\*1024\*1024\*1024) unsigned long int ms\_sz = MAP\_SPACE\_SIZE; …. …. ptr = mmap( NULL, ms\_sz, PROT\_READ|PROT\_...</description></item></channel></rss>