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
+9.4k Golang : Play .WAV file from command line
+9.5k Golang : Get all countries currencies code in JSON format
+13.8k Generate salted password with OpenSSL example
+18.6k Golang : Generate thumbnails from images
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+5.2k Golang : Experimental Jawi programming language
+6.2k Golang : Process non-XML/JSON formatted ASCII text file example
+16.3k Golang : convert string or integer to big.Int type
+21.9k Golang : Use TLS version 1.2 and enforce server security configuration over client
+22.4k Golang : How to read JPG(JPEG), GIF and PNG files ?
+11.6k Golang : Surveillance with web camera and OpenCV