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
+14.5k Golang : Find network of an IP address
+29.5k Golang : Saving(serializing) and reading file with GOB
+17.6k Golang : delete and modify XML file content
+9.2k Golang : Create and shuffle deck of cards example
+5.4k Golang : Get S3 or CloudFront object or file information
+36.4k Golang : Convert date or time stamp from string to time.Time type
+20.9k Golang : Underscore or snake_case to camel case example
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+18.2k Golang : Get command line arguments
+55.3k Golang : Unmarshal JSON from http response
+8.2k Golang : Metaprogramming example of wrapping a function
+26.4k Golang : Get executable name behind process ID example