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
+7.3k Golang : File system scanning
+4.1k Javascript : Empty an array example
+12.2k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter
+6.7k Golang : Check if password length meet the requirement
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+15.3k Golang : Get query string value on a POST request
+16.1k Golang : Generate universally unique identifier(UUID) example
+22.2k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+6.5k Golang : Convert an executable file into []byte example
+35.9k Golang : Integer is between a range
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag