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
+14.2k Golang : Fix image: unknown format error
+10.2k Golang : Text file editor (accept input from screen and save to file)
+7.1k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+26.1k Mac/Linux and Golang : Fix bind: address already in use error
+4.7k Fix Google Analytics Redundant Hostnames problem
+17k Golang : Get input from keyboard
+6.6k Golang : How to determine if request or crawl is from Google robots
+15.2k Golang : How to add color to string?
+5.7k Get website traffic ranking with Similar Web or Alexa
+9.6k Javascript : Read/parse JSON data from HTTP response
+16.8k Golang : read gzipped http response
+11.1k Golang : Read until certain character to break for loop