<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Error on Mi&amp;Bee Blog</title><link>https://blog.mickeyzzc.tech/en/tags/error/</link><description>Recent content in Error on Mi&amp;Bee Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>蓝宝石的傻话</managingEditor><lastBuildDate>Wed, 25 Feb 2026 10:00:00 +0800</lastBuildDate><atom:link href="https://blog.mickeyzzc.tech/en/tags/error/rss.xml" rel="self" type="application/rss+xml"/><item><title>Error Handling: Go's Multi-Return Value Approach</title><link>https://blog.mickeyzzc.tech/en/posts/programming/go-error-handling/</link><pubDate>Wed, 25 Feb 2026 10:00:00 +0800</pubDate><guid>https://blog.mickeyzzc.tech/en/posts/programming/go-error-handling/</guid><description>&lt;p&gt;Go&amp;rsquo;s error handling philosophy is &amp;ldquo;simple, explicit, controllable.&amp;rdquo; Every function that can fail can return an error value, and the caller must explicitly handle it. No exceptions, no implicit propagation—everything is in plain sight.&lt;/p&gt;
&lt;h2 id="the-error-interface-one-value-one-method"&gt;The error Interface: One Value, One Method&lt;/h2&gt;
&lt;p&gt;Go&amp;rsquo;s &lt;code&gt;error&lt;/code&gt; interface is minimal: just one &lt;code&gt;Error() string&lt;/code&gt; method.&lt;/p&gt;
&lt;div class="code-block-wrapper" data-lang="go"&gt;
 &lt;div class="code-block-header"&gt;
 &lt;div class="code-block-meta"&gt;&lt;span class="code-language"&gt;go&lt;/span&gt;&lt;/div&gt;
 
 &lt;button class="copy-button" aria-label="Copy code"&gt;
 &lt;svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"&gt;&lt;rect x="9" y="9" width="13" height="13" rx="2" ry="2"/&gt;&lt;path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/&gt;&lt;/svg&gt;
 &lt;svg class="check-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"&gt;&lt;polyline points="20 6 9 17 4 12"/&gt;&lt;/svg&gt;
 &lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="code-block-body"&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;interface&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This means any type that implements &lt;code&gt;Error() string&lt;/code&gt; is an error. The Go standard library provides many built-in error types, most commonly &lt;code&gt;errors.New&lt;/code&gt; and &lt;code&gt;fmt.Errorf&lt;/code&gt;.&lt;/p&gt;</description></item></channel></rss>