TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Golang :how do i handle index out of range error?

1 点作者 pvsukale1大约 9 年前
I am writing a CLI interface program in Go.my program requires a user to enter a filename as an argument . following is the code I wrote to handle the situations in which user doesn&#x27;t enter any argument . but it panics and gives an error &quot;index out of range&quot;.how do I handle this?<p>if len(os.Args) == 0 { fmt.Println(&quot;usage: gohex &lt;filename&gt;&quot;)<p><pre><code> os.Exit(1) }</code></pre>

暂无评论

暂无评论