Created
June 6, 2013 09:48
-
-
Save bjdean/5720462 to your computer and use it in GitHub Desktop.
thinking about how godoc handles go public/private code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Playing around with how docs are genrated | |
// Indented comments are block-quoted like code# | |
foo := make(Bar, 10) | |
*/ | |
package randomDocs | |
/* | |
Structs - godoc hides lowerCase names | |
In this case MixedStruct also has two 'hidden' fields | |
called startsWithLowerCase and andThisOne: | |
// I wonder if these are hidden? | |
startsWithLowerCase string | |
andThisOne int | |
*/ | |
type MixedStruct struct { | |
// Public fields | |
ThisIsCamelCase string | |
ThisIsToo int | |
// I wonder if these are hidden? | |
startsWithLowerCase string | |
andThisOne int | |
} | |
/* | |
Structs - no public fields | |
this struct contains only hidden fields and no internal comments. | |
mineA string | |
mineB int | |
mineC bool | |
godoc automatically generates "// contains filtered or unexported fields" | |
*/ | |
type NoPubFields struct { | |
mineA string | |
mineB int | |
mineC bool | |
} | |
/* | |
Structs - no public fields, but with a comment | |
this struct contains only hidden fields and one internal comment | |
// this is a comment | |
mineA string | |
mineB int | |
mineC bool | |
The comment is not shown - just the default like NoPubFields | |
*/ | |
type NoPubFieldsWithComment struct { | |
// this is a comment | |
mineA string | |
mineB int | |
mineC bool | |
} | |
// commment before a private function (does not appear in godoc) | |
func myFunction () {} | |
// comment before a public fucntion | |
func YourFunction () {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment