Golang comments: Difference between revisions
From wikinotes
(Created page with "<syntaxhighlight lang="go"> // single line comment →Multiline * Comment: </syntaxhighlight>") |
No edit summary |
||
Line 1: | Line 1: | ||
= Comments = | |||
<blockquote> | |||
<syntaxhighlight lang="go"> | <syntaxhighlight lang="go"> | ||
// single line comment | // single line comment | ||
Line 6: | Line 9: | ||
*/ | */ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Comments --> | |||
= Doc Comments = | |||
<blockquote> | |||
There is no special syntax for doc-comments.<br> | |||
A regular comment preceding any top-level declaration is a doc-comment.<br> | |||
It is customary to have a doc-comment above every exported function. | |||
<syntaxhighlight lang="go"> | |||
// Says hello. | |||
// Prints hello to STDOUT. | |||
func Hello() { | |||
fmt.Println("hello") | |||
} | |||
</syntaxhighlight> | |||
</blockquote><!-- Doc Comments --> |
Revision as of 21:07, 23 May 2022
Comments
// single line comment /* Multiline * Comment */
Doc Comments
There is no special syntax for doc-comments.
A regular comment preceding any top-level declaration is a doc-comment.
It is customary to have a doc-comment above every exported function.// Says hello. // Prints hello to STDOUT. func Hello() { fmt.Println("hello") }