<p>How can i catch a convertion type error? Such as int("test"), how can i catch this error? </p>
<hr/>**评论:**<br/><br/>niosop: <pre><pre><code>i, err := strconv.Atoi("-42")
if err != nil {
//handle error here
}
</code></pre></pre>danredux: <pre><p>Kudos on looking past the naivety and understanding the root question.</p></pre>drvd: <pre><p>No. And it is pointless as this cannot happen at runtime and the compiler will complain loud enough.</p></pre>itsmontoya: <pre><p>What you want to do is use the "ok" value. Here is an <a href="https://play.golang.org/p/D_jWY9OoEA" rel="nofollow">example</a>!</p></pre>