Andrew Gerrand | 5bc444d | 2014-12-10 11:35:11 +1100 | [diff] [blame] | 1 | # Comments |
| 2 | |
| 3 | Every package should have a package comment. It should immediately precede the ` package ` statement in one of the files in the package. (It only needs to appear in one file.) It should begin with a single sentence that begins "Package _packagename_" and give a concise summary of the package functionality. This introductory sentence will be used in godoc's list of all packages. |
| 4 | |
| 5 | Subsequent sentences and/or paragraphs can give more details. Sentences should be properly punctuated. |
| 6 | |
nathany | 814c219 | 2014-12-10 22:02:06 -0800 | [diff] [blame] | 7 | ```go |
Andrew Gerrand | 5bc444d | 2014-12-10 11:35:11 +1100 | [diff] [blame] | 8 | // Package superman implements methods for saving the world. |
| 9 | // |
| 10 | // Experience has shown that a small number of procedures can prove |
| 11 | // helpful when attempting to save the world. |
| 12 | package superman |
| 13 | ``` |
| 14 | |
| 15 | Nearly every top-level type, const, var and func should have a comment. A comment for bar should be in the form "_bar_ floats on high o'er vales and hills.". The first letter of _bar_ should not be capitalized unless it's capitalized in the code. |
| 16 | |
nathany | 814c219 | 2014-12-10 22:02:06 -0800 | [diff] [blame] | 17 | ```go |
Andrew Gerrand | 5bc444d | 2014-12-10 11:35:11 +1100 | [diff] [blame] | 18 | // enterOrbit causes Superman to fly into low Earth orbit, a position |
| 19 | // that presents several possibilities for planet salvation. |
| 20 | func enterOrbit() os.Error { |
| 21 | ... |
| 22 | } |
| 23 | ``` |