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
+10.2k Golang : Find and replace data in all files recursively
+10.1k Golang : Print how to use flag for your application example
+12.6k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+6.1k Golang : Missing Subversion command
+6.8k Golang : Get expvar(export variables) to work with multiplexer
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+10.1k Golang : Test a slice of integers for odd and even numbers
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)
+20.6k Golang : Secure(TLS) connection between server and client
+17.5k Golang : Clone with pointer and modify value
+11.3k Golang : Byte format example