Golang go/ast.DeferStmt type, End() and Pos() functions examples
package go/ast
A DeferStmt node represents a defer statement.
Golang go/ast.DeferStmt type, End() and Pos() functions examples
Example 1:
func NodeDescription(n ast.Node) string {
switch n := n.(type) {
case *ast.ArrayType:
return "array type"
case *ast.AssignStmt:
return "assignment"
case *ast.DeferStmt:
return "defer statement"
...
}
Example 2:
func checkCurrentPosition(node ast.Node) string {
n := node.(*ast.DeferStmt)
endpos := n.End()
pospos := n.Pos()
if pospos != endpos {
return "not yet"
}
}
References :
http://golang.org/pkg/go/ast/#DeferStmt
Advertisement
Something interesting
Tutorials
+11.6k Android Studio : Create custom icons for your application example
+16.4k Golang : Send email and SMTP configuration example
+11.2k Google Maps URL parameters configuration
+36.7k Golang : Display float in 2 decimal points and rounding up or down
+5.1k Golang : Display packages names during compilation
+5.6k Python : Print unicode escape characters and string
+9.4k Golang : Play .WAV file from command line
+11.6k Swift : Convert (cast) Float to String
+12.4k Golang : Extract part of string with regular expression
+8k Golang : What fmt.Println() can do and println() cannot do
+15k Golang : Search folders for file recursively with wildcard support
+6.1k Golang : Dealing with backquote