code: func newDirectory(root string, maxDepth int) *Directory {
  	// The root could be a symbolic link so use Stat not Lstat.
  	d, err := os.Stat(root)
  	// If we fail here, report detailed error messages; otherwise
  	// is is hard to see why a directory tree was not built.
  	switch {
  	case err != nil:
  		log.Printf("newDirectory(%s): %s", root, err)
  		return nil
  	case !isPkgDir(d):
  		log.Printf("newDirectory(%s): not a package directory", root)
  		return nil
  	}
  	if maxDepth < 0 {
  		maxDepth = 1e6 // "infinity"
  	}
  	b := treeBuilder{maxDepth}
  	// the file set provided is only for local parsing, no position
  	// information escapes and thus we don't need to save the set
  	return b.newDirTree(token.NewFileSet(), root, d.Name(), 0)
  }
docs: // newDirectory creates a new package directory tree with at most maxDepth
  // levels, anchored at root. The result tree is pruned such that it only
  // contains directories that contain package files or that contain
  // subdirectories containing package files (transitively). If a non-nil
  // pathFilter is provided, directory paths additionally must be accepted
  // by the filter (i.e., pathFilter(path) must be true). If a value >= 0 is
  // provided for maxDepth, nodes at larger depths are pruned as well; they
  // are assumed to contain package files even if their contents are not known
  // (i.e., in this case the tree may contain directories w/o any package files).
  //