According to "Effective Go" golang.org/doc/effective_go
Every exported (capitalized) name in a program should have a doc comment.
Let's say I have a view handler on a simple web application
// Handle the front page of the website
func FrontPageView(w http.ResponseWriter, r *http.Request) {
controllers.RenderBasicPage(w, "frontPage")
}
My question is this: is that godoc really necessary? Perhaps I'm just in love with Robert Martin's Clean Code right now, but it seems an effectively named variable, in this case FrontPageView removes the need for such a godoc. This is probably a derivative/duplicate of "are javadocs necessary?" or "are python docstrings necessary?", but I do want to make sure that when learning a new language I'm sticking to the language-specific canonical ways-to-do-things.
Note that golint would tell you that the doc for FrontPageView() must start with
And yes, it is good practice to include (here a short) comment on all exported methods, functions, as described also in "Go Code Review Comments".
Then the doc can include edge cases (even if in your case there are none).
In any case, adding a short doc won't make it "less clean".
I use gocyclo for this: any cyclomatic complexity above 10, and I split the function.
That is the idea: keeping the doc in sync (and
golinthelps)