Golang go/ast.ForStmt type example

package go/ast

A ForStmt represents a for statement.

Golang go/ast.ForStmt 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.ForStmt:
 return "for loop"
 }

Reference :

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

Advertisement