<article class="til">
<header><h1 id="til-using-errors-is-in-go">Using errors.Is in Go</h1></header>
<p>I learned today that <code>errors.Is</code> unwraps wrapped errors automatically.</p>
<pre><code class="language-go">package main
import (
"errors"
"fmt"
)
func main() {
a := errors.New("boom")
b := fmt.Errorf("wrapped: %w", a)
fmt.Println(errors.Is(b, a))
}
</code></pre>
<p>That prints <code>true</code>.</p>
<footer class="tags">
<a href="/tags/go/">go</a>
<a href="/tags/errors/">errors</a>
</footer>
</article>