Is this really a convention in Go?

Written by
reddit
Link to Post

https://www.reddit.com/r/golang/comments/b0wm7z/is_this_really_a_convention_in_go/ by 

Our programs have lots of comments like this:

// NewServer returns a new server func NewServer() *Server { s := &Server{ } return s } 

Obviously this comment is useless. Instead of saying “why” something is being done, it says “what” is being done. And actually it is not even doing that — it’s only identical to, say, Java’s @return JavaDoc tag.

I asked my colleagues why and the response was:

  • The Go linter expects every function to have comments
  • The convention is to start comments with name of the function

Is there any way not to do this while keeping the linter happy?

submitted by /u/GoRune
[link] [comments]

Article Tags:
· ·
Article Categories:
reddit

Leave a Reply