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.4k Golang : How to convert a number to words
+5.4k Javascript : How to loop over and parse JSON data?
+9.4k Golang : Web(Javascript) to server-side websocket example
+7.3k Golang : File system scanning
+22.5k Golang : Convert Unix timestamp to UTC timestamp
+4.7k Adding Skype actions such as call and chat into web page examples
+14.4k Golang : How to pass map to html template and access the map's elements
+22.9k Golang : Test file read write permission example
+25.8k Golang : Daemonizing a simple web server process example
+9.7k Golang : Eroding and dilating image with OpenCV example
+20k Golang : How to run your code only once with sync.Once object
+7.1k Golang : Get environment variable