Golang go/ast.BranchStmt type example

package go/ast

A BranchStmt node represents a break, continue, goto, or fallthrough statement.

Golang go/ast.BranchStmt type usage example

 func NodeDescription(n ast.Node) string {
 switch n := n.(type) {
 case *ast.ArrayType:
 return "array type"
 case *ast.AssignStmt:
 return "assignment"
 case *ast.BranchStmt:
 switch n.Tok {
 case token.BREAK:
 return "break statement"
 case token.CONTINUE:
 return "continue statement"
 case token.GOTO:
 return "goto statement"
 case token.FALLTHROUGH:
 return "fall-through statement"
 }
 ...
 }

Reference :

http://golang.org/pkg/go/ast/#BranchStmt

Advertisement