Go - Comments
Beginner 10/10
Teacher 10/10
Architect 10/10
Try it: Add a doc comment above a function starting with its name.
Comments
// line comment
/* block
comment */
Doc Comments
Start with the name of the package, function, type, or var for best go doc
results.
Common errors
- Doc comments not starting with the identifier name;
go doc
uses these conventions.
Practice
- Write a doc comment for your
main
package and rungo doc
.
Quick quiz
- Why start doc comments with the name of the item?
Show answer
It improves tooling output (go doc
) and clarity.