Golang go/ast.Ellipsis type, End() and Pos() functions examples
package go/ast
An Ellipsis node stands for the "..." type in a parameter list or the "..." length in an array type.
Golang go/ast.Ellipsis type, End() and Pos() functions 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.Ellipsis:
return "ellipsis"
...
}
Example 2:
func checkCurrentPosition(node ast.Node) string {
n := node.(*ast.Ellipsis)
endpos := n.End()
pospos := n.Pos()
if pospos != endpos {
return "not yet"
}
}
References :
http://golang.org/pkg/go/ast/#Ellipsis
Advertisement
Something interesting
Tutorials
+22.7k Golang : Round float to precision example
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+40.1k Golang : UDP client server read write example
+4.8k PHP : Extract part of a string starting from the middle
+7.9k Setting $GOPATH environment variable for Unix/Linux and Windows
+18.1k Golang : Convert IPv4 address to decimal number(base 10) or integer
+11.3k Golang : Intercept and process UNIX signals example
+4k Detect if Google Analytics and Developer Media are loaded properly or not
+6.8k Golang : Muxing with Martini example
+14.5k Golang : How to determine if user agent is a mobile device example
+18.6k Golang : Get download file size
+6.5k Golang : Handling image beyond OpenCV video capture boundary