Golang go/ast.NewIdent() function example
package go/ast
NewIdent creates a new Ident without position. Useful for ASTs generated by code other than the Go parser.
Golang go/ast.NewIdent() function usage example
var varVar = flag.String("var", "GoCover", "name of coverage variable to generate")
func (f *File) newCounter(start, end token.Pos, numStmt int) ast.Stmt {
counter := &ast.IndexExpr{
X: &ast.SelectorExpr{
X: ast.NewIdent(*varVar), // <-- here
Sel: ast.NewIdent("Count"),
},
Index: f.index(),
}
stmt := counterStmt(f, counter)
f.blocks = append(f.blocks, Block{start, end, numStmt})
return stmt
}
References :
https://github.com/lattera/go.tools/blob/master/cmd/cover/cover.go
Advertisement
Something interesting
Tutorials
+8.2k Golang : Qt splash screen with delay example
+18.4k Golang : Logging with logrus
+5.9k Golang : Detect variable or constant type
+11.1k Golang : Web routing/multiplex example
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+12.4k Golang : Search and extract certain XML data example
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+14.6k Golang : Missing Bazaar command
+11.4k Golang : Concatenate (combine) buffer data example
+5.2k Golang : Experimental Jawi programming language
+29.5k Golang : How to create new XML file ?
+17.5k Golang : Find smallest number in array