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
+7.4k Android Studio : How to detect camera, activate and capture example
+41.2k Golang : How to count duplicate items in slice/array?
+6.4k Golang : How to search a list of records or data structures
+12.1k Golang : md5 hash of a string
+9.5k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+33.8k Golang : convert(cast) bytes to string
+6.1k Golang : Debug with Godebug
+14.6k Golang : Convert(cast) int to float example
+5.7k Unix/Linux/MacOSx : Get local IP address
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+4.8k Which content-type(MIME type) to use for JSON data
+12.2k Golang : Simple client-server HMAC authentication without SSL example