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
+23.7k Find and replace a character in a string in Go
+19.1k Golang : When to use public and private identifier(variable) and how to make the identifier public or private?
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+12.4k Golang : Search and extract certain XML data example
+30k Golang : Get time.Duration in year, month, week or day
+47.8k Golang : Convert int to byte array([]byte)
+14.4k Golang : Parsing or breaking down URL
+14.2k Golang : Chunk split or divide a string into smaller chunk example
+21.6k Golang : Encrypt and decrypt data with TripleDES
+8.2k Golang : Reverse text lines or flip line order example
+6.3k WARNING: UNPROTECTED PRIVATE KEY FILE! error message
+15.7k Golang : Get checkbox or extract multipart form data value example