<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/">

  <channel>
    <title>inasayang&#39;s blog</title>
    <link>/</link>
    <description>Recent blog posts on inasayang&#39;s blog</description>
    
    <generator>Hugo (https://gohugo.io)</generator>
    
    <language>zh-cn</language>
    
    <managingEditor>xiayangzzw@gmail.com (inasayang)</managingEditor>
    
    <webMaster>xiayangzzw@gmail.com (inasayang)</webMaster>
    
    <lastBuildDate>Tue, 08 Aug 2023 00:00:00 Z</lastBuildDate>
    
    <atom:link href="/tags/struct/index.xml" rel="self" type="application/rss+xml" />
    

    <item>
      <title>Go | 使一个结构体类型不可比较</title>
      <link>/posts/230808_gomakestructnotcompare/</link>
      <pubDate>Tue, 08 Aug 2023 00:00:00 Z</pubDate>
      
      <author>xiayangzzw@gmail.com (inasayang)</author>

      
      
      
      

      <description>
      
      </description>
      <content:encoded>&lt;p&gt;可以放置一个非导出的零尺寸的不可比较类型的字段在结构体类型中以使此结构体类型不可比较&lt;/p&gt;
&lt;p&gt;结构体&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;type T struct {
	dummy [0]func()
	AnotherField int
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;使用&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;var x map[T]int // 编译错误：非法的键值类型

var a, b T
_ = a == b // 编译错误：非法的比较
&lt;/code&gt;&lt;/pre&gt;</content:encoded>
      
      <category>go</category>
      
      <category>struct</category>
      
      
      <guid isPermaLink="true">/posts/230808_gomakestructnotcompare/</guid>
    </item>
    
  </channel>
</rss>
