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
+7.5k Golang : Get YouTube playlist
+25.8k Golang : Daemonizing a simple web server process example
+41.4k Golang : Convert string to array/slice
+13.3k Golang : Date and Time formatting
+15.9k Golang : Read a file line by line
+18k Golang : Get all upper case or lower case characters from string example
+22.9k Golang : Test file read write permission example
+10.2k Golang : Find and replace data in all files recursively
+11.8k Golang : GTK Input dialog box examples
+7.5k Golang : Rot13 and Rot5 algorithms example
+26.7k Golang : How to check if a connection to database is still alive ?
+14.4k Golang : How to convert a number to words