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
+8.8k Golang : Take screen shot of browser with JQuery example
+30k Golang : Get time.Duration in year, month, week or day
+16k Golang : Read large file with bufio.Scanner cause token too long error
+10.6k Golang : Simple File Server
+26.7k Golang : How to check if a connection to database is still alive ?
+5.5k Golang : Stop goroutine without channel
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+21.2k Golang : How to get time zone and load different time zone?
+11.6k Golang : Fuzzy string search or approximate string matching example
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+19.8k Golang : Append content to a file
+11.5k Golang : Generate DSA private, public key and PEM files example