<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>类型系统 on PlumePHP</title><link>https://plumephp.com/tags/%E7%B1%BB%E5%9E%8B%E7%B3%BB%E7%BB%9F/</link><description>Recent content in 类型系统 on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Wed, 13 Aug 2025 10:00:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/%E7%B1%BB%E5%9E%8B%E7%B3%BB%E7%BB%9F/index.xml" rel="self" type="application/rss+xml"/><item><title>Go 1.18 any 与 interface{} 深度对比：类型别名背后的演进与最佳实践</title><link>https://plumephp.com/go-118-any-vs-interface-2022/</link><pubDate>Wed, 13 Aug 2025 10:00:00 +0800</pubDate><guid>https://plumephp.com/go-118-any-vs-interface-2022/</guid><description>&lt;h2 id="any-的诞生背景为什么-go-需要一个新的名字"&gt;any 的诞生背景：为什么 Go 需要一个新的名字&lt;/h2&gt;
&lt;p&gt;Go 1.18 是 Go 语言发展史上的里程碑版本，它不仅带来了万众期待的泛型（Generics），还同时引入了一个看似微小实则影响深远的预声明标识符：&lt;code&gt;any&lt;/code&gt;。很多初学者第一次看到 &lt;code&gt;any&lt;/code&gt; 时会误以为这是一种全新类型，拥有某种特殊的运行时语义。然而事实上，&lt;code&gt;any&lt;/code&gt; 仅仅是 &lt;code&gt;interface{}&lt;/code&gt; 的一个类型别名（type alias），在编译器层面二者完全等价。&lt;/p&gt;</description></item><item><title>Go 空接口与类型断言深度解析：从 interface{} 内存布局到泛型替代趋势</title><link>https://plumephp.com/go-empty-interface-and-type-assertions/</link><pubDate>Wed, 13 Aug 2025 10:00:00 +0800</pubDate><guid>https://plumephp.com/go-empty-interface-and-type-assertions/</guid><description>&lt;h2 id="空接口能装任何值但代价是你要自己判断"&gt;空接口能装任何值，但代价是你要自己判断&lt;/h2&gt;
&lt;p&gt;Go 里 &lt;code&gt;interface{}&lt;/code&gt; 是一个很特别的类型。因为它没有要求任何方法，所以所有类型都实现了它。字符串、整数、结构体、切片、指针，都可以赋给 &lt;code&gt;interface{}&lt;/code&gt;。这让它很灵活，也很容易被滥用。&lt;/p&gt;</description></item></channel></rss>