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
+5.3k Golang : How to deal with configuration data?
+32.4k Golang : Math pow(the power of x^y) example
+13.5k Facebook PHP getUser() returns 0
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+19.1k Mac OSX : Homebrew and Golang
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+7.8k Golang : Example of how to detect which type of script a word belongs to
+5.1k Golang : Display packages names during compilation
+36.6k Golang : Validate IP address
+10.6k Golang : Resolve domain name to IP4 and IP6 addresses.
+22.1k Golang : Join arrays or slices example