<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《Go 1.22新特性前瞻》的评论</title>
	<atom:link href="http://tonybai.com/2023/12/25/go-1-22-foresight/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2023/12/25/go-1-22-foresight/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Wed, 25 Mar 2026 09:21:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2023/12/25/go-1-22-foresight/#comment-7741</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Wed, 17 Jan 2024 04:50:21 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=4087#comment-7741</guid>
		<description>到目前为止，我还没在生产代码中使用过slices包。我看了一下关于Go 1.22中slices.Delete等函数的更新的原始issue - https://github.com/golang/go/issues/63393 ，从讨论的上下文来看，zero的目的是for GC：

clear(s[len(s):oldlen]) // zero/nil out the obsolete elements, for GC

如果我们的切片只是简单的整型切片，这么做意义的确不大。但是如果slice中存储的是指针，那么zero后，指针指向的heap object就可以被gc释放了，但如果不zero，这部分obsolete elements指向的heap object依旧会存在，直到slice的生命周期结束。</description>
		<content:encoded><![CDATA[<p>到目前为止，我还没在生产代码中使用过slices包。我看了一下关于Go 1.22中slices.Delete等函数的更新的原始issue &#8211; <a href="https://github.com/golang/go/issues/63393" rel="nofollow">https://github.com/golang/go/issues/63393</a> ，从讨论的上下文来看，zero的目的是for GC：</p>
<p>clear(s[len(s):oldlen]) // zero/nil out the obsolete elements, for GC</p>
<p>如果我们的切片只是简单的整型切片，这么做意义的确不大。但是如果slice中存储的是指针，那么zero后，指针指向的heap object就可以被gc释放了，但如果不zero，这部分obsolete elements指向的heap object依旧会存在，直到slice的生命周期结束。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：dseven</title>
		<link>https://tonybai.com/2023/12/25/go-1-22-foresight/#comment-7740</link>
		<dc:creator>dseven</dc:creator>
		<pubDate>Tue, 16 Jan 2024 06:30:24 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=4087#comment-7740</guid>
		<description>大白老师，如何看待go1.22中对slice的Delete等方法的更新？感觉这样做兼容性差，而且实在想不出改变原始切片中的值为0有什么优点</description>
		<content:encoded><![CDATA[<p>大白老师，如何看待go1.22中对slice的Delete等方法的更新？感觉这样做兼容性差，而且实在想不出改变原始切片中的值为0有什么优点</p>
]]></content:encoded>
	</item>
</channel>
</rss>
