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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Opinions about commentary in Golang

2 点作者 shivylp超过 6 年前
Go convention is to write comments for every entity in a package that is exposed (starts with an upper case letter). Even linter complains about not commenting. I have heard people argue over this saying some things shouldn&#x27;t be commented if they&#x27;re obvious enough.<p>I agree that obvious things don&#x27;t really <i>need</i> a comment. But the problem of commenting only certain things as opposed to all things, is inconsistency across codebase. If new developer looks at the code and sees comments only at certain places, it might feel like the comments aren&#x27;t trustworthy since there is no standard pattern. Also, I believe the term <i>obvious</i> itself is not objective (at the time of writing the code, most of the stuff are obvious)..<p>What do you all think ?

1 comment

jerf超过 6 年前
For pretty much the reasons you give, I comment everything the linter wants commented. Sometimes the comment is just &quot;Read implements io.Reader.&quot; or &quot;$STRUCT is only exposed publicly for encoding&#x2F;json, you should not use it.&quot;<p>You may find more success posting this sort of thing at reddit.com&#x2F;r&#x2F;golang, or some other dedicated Go community.
评论 #18155283 未加载