// rewrite filename to include importPath.
rewrite filename to include importPath.
// rewrite filename to include importPath .
func rewriteFile(fset *token.FileSet, pf *ast.File, filename, importPath string) error {
	log.Printf("package: %q, rewriting %q", importPath, filename)
	cmap := ast.NewCommentMap(fset, pf, pf.Comments)
	if cmap == nil {
		cmap = make(ast.CommentMap)
	}
	com := &ast.Comment{Slash: pf.Name.End(), Text: `// import "` + importPath + `"`}
	cmap[pf.Name] = []*ast.CommentGroup{{List: []*ast.Comment{com}}}
	pf.Comments = cmap.Comments()
	if !*dryrun {
		var buf bytes.Buffer
		if err := format.Node(&buf, fset, pf); err != nil {
			return err
		}
		return ioutil.WriteFile(filename, buf.Bytes(), 0644)
	}
	return nil
}
func rewriteFile ( fset * token . FileSet , pf * ast . File , filename , importPath string ) error { log . Printf ( " " , importPath , filename ) cmap := ast . NewCommentMap ( fset , pf , pf . Comments ) if cmap == nil { cmap = make ( ast . CommentMap ) } com := & ast . Comment { Slash : pf . Name . End ( ) , Text : `// import "` + importPath + `"` } cmap [ pf . Name ] = [ ] * ast . CommentGroup { { List : [ ] * ast . Comment { com } } } pf . Comments = cmap . Comments ( ) if ! * dryrun { var buf bytes . Buffer if err := format . Node ( & buf , fset , pf ) ; err != nil { return err } return ioutil . WriteFile ( filename , buf . Bytes ( ) , 0644 ) } return nil }
rewrite filename to include importPath.
rewrite filename to include importPath .
// add comment containing canonical import path