Golang go/ast.EmptyStmt type, End() and Pos() functions examples
package go/ast
An EmptyStmt node represents an empty statement. The "position" of the empty statement is the position of the immediately preceding semicolon.
Golang go/ast.EmptyStmt type, End() and Pos() functions usage 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.EmptyStmt:
return "empty statement"
...
}
Example 2:
func checkCurrentPosition(node ast.Node) string {
n := node.(*ast.EmptyStmt)
endpos := n.End()
pospos := n.Pos()
if pospos != endpos {
return "not yet"
}
}
References :
http://golang.org/pkg/go/ast/#EmptyStmt
Advertisement
Something interesting
Tutorials
+13.7k Golang : Tutorial on loading GOB and PEM files
+17.4k Golang : Check if IP address is version 4 or 6
+9.8k Golang : Qt get screen resolution and display on center example
+8k Golang : Get all countries phone codes
+14.3k Golang : How to shuffle elements in array or slice?
+8.1k Golang : HTTP Server Example
+10.5k Golang : Select region of interest with mouse click and crop from image
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+17.5k Golang : Find smallest number in array
+37.5k Upload multiple files with Go
+6.4k Golang : Break string into a slice of characters example