Documentation ¶
Overview ¶
Package comment provide one method for read the comments which in struct, method and function.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDirComment ¶
func GetDirComment(filter func(f os.FileInfo) bool, dirs ...string) (sc StructComment, mc MethodComment, fc FuncComment, e error)
Example ¶
package main import ( "fmt" "gopkg.in/orivil/comment.v0" "log" "os" ) // controller comment type controller struct { } // @route {get}/ func (c *controller) index() { } // add two parameters func add(a, b int) int { return a + b } func main() { fileFilter := func(f os.FileInfo) bool { // match all file return true } structComment, methodComment, functionComment, err := comment.GetDirComment(fileFilter, "./") if err != nil { log.Fatal(err) } // get struct comment fmt.Println(structComment["comment_test.controller"] == "controller comment\n") // get method comment fmt.Println(methodComment["comment_test.controller"]["index"] == "@route {get}/\n") // get function comment fmt.Println(functionComment["comment_test.add"] == "add two parameters\n") }
Output: true true true
Types ¶
type FuncComment ¶
type MethodComment ¶
type StructComment ¶
Click to show internal directories.
Click to hide internal directories.