refactor/eg: use format.Node not printer.Fprint for canonical output

Fixes golang/go#10038

Change-Id: If3243f0c68fc0442dcc1e2dd71cbdc629beff70c
Reviewed-on: https://go-review.googlesource.com/6481
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
diff --git a/refactor/eg/eg.go b/refactor/eg/eg.go
index a107204..7d37ec6 100644
--- a/refactor/eg/eg.go
+++ b/refactor/eg/eg.go
@@ -6,6 +6,7 @@
 	"bytes"
 	"fmt"
 	"go/ast"
+	"go/format"
 	"go/printer"
 	"go/token"
 	"os"
@@ -288,7 +289,7 @@
 			err = err2 // prefer earlier error
 		}
 	}()
-	return printer.Fprint(fh, fset, f)
+	return format.Node(fh, fset, f)
 }
 
 // -- utilities --------------------------------------------------------
diff --git a/refactor/eg/testdata/A1.golden b/refactor/eg/testdata/A1.golden
index 4f7ba82..7eb2934 100644
--- a/refactor/eg/testdata/A1.golden
+++ b/refactor/eg/testdata/A1.golden
@@ -3,8 +3,8 @@
 package A1
 
 import (
-	. "fmt"
 	"errors"
+	. "fmt"
 	myfmt "fmt"
 	"os"
 	"strings"
diff --git a/refactor/eg/testdata/A2.golden b/refactor/eg/testdata/A2.golden
index 5c2384b..b6e3a6d 100644
--- a/refactor/eg/testdata/A2.golden
+++ b/refactor/eg/testdata/A2.golden
@@ -6,8 +6,8 @@
 // TODO(adonovan): fix: it should also remove "fmt".
 
 import (
-	myfmt "fmt"
 	"errors"
+	myfmt "fmt"
 )
 
 func example(n int) {
diff --git a/refactor/eg/testdata/D1.golden b/refactor/eg/testdata/D1.golden
index 3f2dc59..2932652 100644
--- a/refactor/eg/testdata/D1.golden
+++ b/refactor/eg/testdata/D1.golden
@@ -5,8 +5,8 @@
 import "fmt"
 
 func example() {
-	fmt.Println(456, "!")		// match
-	fmt.Println(456, "!")		// match
-	fmt.Println(456, "!")		// match
-	fmt.Println(100+20+3, "a"+"")	// no match: constant expressions, but not basic literals
+	fmt.Println(456, "!")         // match
+	fmt.Println(456, "!")         // match
+	fmt.Println(456, "!")         // match
+	fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals
 }
diff --git a/refactor/eg/testdata/E1.golden b/refactor/eg/testdata/E1.golden
index a0adfc8..796364f 100644
--- a/refactor/eg/testdata/E1.golden
+++ b/refactor/eg/testdata/E1.golden
@@ -3,11 +3,11 @@
 package E1
 
 import (
+	"fmt"
 	"log"
 	"os"
-	"fmt"
 )
 
 func example() {
-	fmt.Fprintf(os.Stderr, "warning: %v", "oops")	// match
+	fmt.Fprintf(os.Stderr, "warning: %v", "oops") // match
 }