// (i.e., whether it begins with an uppercase letter).
func (name *Ident) IsExported() bool { return IsExported(name.Value) }
-func (name *Ident) String() string { return name.Value }
+func (name *Ident) String() string {
+ if name != nil {
+ return name.Value
+ }
+ return "<nil>"
+}
// ----------------------------------------------------------------------------
TypeSpec struct {
Doc *CommentGroup // associated documentation; or nil
Name *Ident // type name
- Type Expr
+ Type Expr // *ArrayType, *StructType, *FuncType, *InterfaceType, *MapType, *ChanType or *Ident
Comment *CommentGroup // line comments; or nil
}
)
// followed by a call of w.Visit(nil).
//
// Walk may be called with any of the named ast node types. It also
-// accepts arguments of type []*Field, []*Ident, []Expr and []Stmt;
+// accepts arguments of type []*Field, []*Ident, []Expr, []Stmt and []Decl;
// the respective children are the slice elements.
//
func Walk(v Visitor, node interface{}) {
case *File:
walkCommentGroup(v, n.Doc)
walkIdent(v, n.Name)
- for _, d := range n.Decls {
- Walk(v, d)
- }
+ Walk(v, n.Decls)
walkCommentGroup(v, n.Comments)
case *Package:
Walk(v, x)
}
+ case []Decl:
+ for _, x := range n {
+ Walk(v, x)
+ }
+
default:
fmt.Printf("ast.Walk: unexpected type %T", n)
panic()