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
+12.7k Golang : Add ASCII art to command line application launching process
+37.5k Upload multiple files with Go
+7.7k Gogland : Where to put source code files in package directory for rookie
+18.8k Golang : Delete duplicate items from a slice/array
+9.2k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+7.6k Android Studio : AlertDialog to get user attention example
+8.9k Golang : Sort lines of text example
+7.4k Golang : Individual and total number of words counter example
+8.7k Golang : Combine slices but preserve order example
+20.6k Golang : Secure(TLS) connection between server and client