Is this really a convention in Go?

Written by
Link to Post 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:

Leave a Reply