code: func (p *parser) recordImport(f *ast.File, typ ast.Expr) error {
  	if star, ok := typ.(*ast.StarExpr); ok {
  		typ = star.X
  	}
  
  	sel, ok := typ.(*ast.SelectorExpr)
  	if !ok {
  		return nil
  	}
  	pkgID, ok := sel.X.(*ast.Ident)
  	if !ok {
  		return nil
  	}
  
  	if _, ok := p.extraImports[pkgID.Name]; ok {
  		return nil
  	}
  
  	path := ""
  	for _, i := range f.Imports {
  		if i.Name.Name == pkgID.Name {
  			path = strings.Trim(i.Path.Value, `"`)
  			break
  		}
  	}
  	if path == "" {
  		return fmt.Errorf("could not resolve package %s", pkgID.Name)
  	}
  	if p.extraImports == nil {
  		p.extraImports = make(map[string]string)
  	}
  	p.extraImports[pkgID.Name] = path
  	return nil
  }
docs: // recordImport extracts the package referenced by type expression typ,
  // resolves its path and saves to p.extraImports.