Skip to content

Instantly share code, notes, and snippets.

@bjdean
Created June 6, 2013 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjdean/5720462 to your computer and use it in GitHub Desktop.
Save bjdean/5720462 to your computer and use it in GitHub Desktop.
thinking about how godoc handles go public/private code
/*
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