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
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+4.8k Golang : A program that contain another program and executes it during run-time
+10.6k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+13.6k Android Studio : Password input and reveal password example
+10.6k Golang : How to delete element(data) from map ?
+29.1k Golang : Get first few and last few characters from string
+23.9k Golang : Fix type interface{} has no field or no methods and type assertions example
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+7.4k Golang : Convert source code to assembly language
+40.1k Golang : UDP client server read write example
+18.3k Golang : Get path name to current directory or folder
+6.6k Golang : Warp text string by number of characters or runes example