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
+7k Golang : How to call function inside template with template.FuncMap
+17.2k Golang : When to use init() function?
+26.4k Golang : Get executable name behind process ID example
+5.6k Fix fatal error: evacuation not done in time problem
+15.7k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+9.2k Golang : Create and shuffle deck of cards example
+11.6k SSL : The certificate is not trusted because no issuer chain was provided
+8.4k Your page has meta tags in the body instead of the head
+21.5k Golang : How to read float value from standard input ?
+33.7k Golang : All update packages with go get command
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+9.1k Golang : How to capture return values from goroutines?