Golang comments: Difference between revisions
From wikinotes
Line 16: | Line 16: | ||
The docs recommend that they begin with the name of the function. | The docs recommend that they begin with the name of the function. | ||
It is customary to have a doc-comment above every exported function. | It is customary to have a doc-comment above every exported function,<br> | ||
and preceding a package statement (any package statement, often there is a <code>doc.go</code> for this comment). | |||
<syntaxhighlight lang="go"> | <syntaxhighlight lang="go"> |
Revision as of 03:31, 25 May 2022
Comments
// single line comment /* Multiline * Comment */
Doc Comments
Doc-comments are regular comments that preceed a top-level declaration.
The docs recommend that they begin with the name of the function.It is customary to have a doc-comment above every exported function,
and preceding a package statement (any package statement, often there is adoc.go
for this comment).// Hello prints hello to STDOUT. // If you'd like to ... etc etc func Hello() { fmt.Println("hello") }You can search documentation by by type in your cli
go doc -all regexp # print docs for all methods with regexp type in method signature (?)