Golang go/ast.CommentMap type and NewCommentMap() function example
package go/ast
A CommentMap maps an AST node to a list of comment groups associated with it. See NewCommentMap for a description of the association.
Golang go/ast.CommentMap type and NewCommentMap() function usage example
Example( taken from http://golang.org/pkg/go/ast/#CommentMap )
// Create the AST by parsing src.
fset := token.NewFileSet() // positions are relative to fset
f, err := parser.ParseFile(fset, "src.go", src, parser.ParseComments)
if err != nil {
panic(err)
}
// Create an ast.CommentMap from the ast.File's comments.
// This helps keeping the association between comments
// and AST nodes.
cmap := ast.NewCommentMap(fset, f, f.Comments)
References :
Advertisement
Something interesting
Tutorials
+5k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+16.1k Golang : How to check if input from os.Args is integer?
+6.8k Golang : Muxing with Martini example
+10.6k Golang : How to delete element(data) from map ?
+8.1k Golang : Get all countries phone codes
+14.6k Golang : Send email with attachment(RFC2822) using Gmail API example
+17.8k Golang : Iterate linked list example
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+12.7k Golang : zlib compress file example
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package