Go Concepts - Documentation: Difference between revisions
Jump to navigation
Jump to search
Line 41: | Line 41: | ||
==Package-Level Documentation== | ==Package-Level Documentation== | ||
<font color=red>'''TODO'''</font> | |||
==Package Identifier Documentation== | ==Package Identifier Documentation== |
Revision as of 02:27, 2 April 2016
Internal
Overview
Go generates in-line documentation for symbols in packages, via the go doc command.
Reading Documentation
To read the package summary:
go doc <package-path>
where the package-path is the same string literal used in the import statement.
Example:
go doc fmt go doc project1/blue
To get the documentation for a package identifier (function name, type, etc):
go doc <package-path> <identifier>
Example:
go doc fmt Println go doc project1/blue Blue
Writing Documentation
Package-Level Documentation
TODO
Package Identifier Documentation
Add a "//" comment before the exported identifier (function, type, etc).
Example:
// This function pains all its arguments blue fun Blue(s string) string { ... }
go doc will work as follows:
go doc blue Blue func Blue(s string) string This function paints all its arguments blue