]> Cypherpunks repositories - gostls13.git/commitdiff
go/printer, gofmt: use blank to separate import rename from import path
authorRobert Griesemer <gri@golang.org>
Fri, 8 Apr 2011 22:47:21 +0000 (15:47 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 8 Apr 2011 22:47:21 +0000 (15:47 -0700)
Note that declarations.golden is not using spaces for alignment (so
that the alignment tabs are visible) which is why this change affects
the test cases significantly. gofmt uses spaces for alignment (by default)
and only tabs for indentation.

gofmt -w src misc (no changes)

Fixes #1673.

R=iant
CC=golang-dev
https://golang.org/cl/4388044

src/pkg/go/printer/nodes.go
src/pkg/go/printer/testdata/declarations.golden
src/pkg/go/printer/testdata/declarations.input

index 0b3b6621e6c1513506163e31499b46d570176bc2..86c32793062cbbe3313dd70430894a5adbe891a1 100644 (file)
@@ -1200,7 +1200,7 @@ func (p *printer) spec(spec ast.Spec, n int, doIndent bool, multiLine *bool) {
                p.setComment(s.Doc)
                if s.Name != nil {
                        p.expr(s.Name, multiLine)
-                       p.print(vtab)
+                       p.print(blank)
                }
                p.expr(s.Path, multiLine)
                p.setComment(s.Comment)
index 1c091b9295e368baa5e1cdd0b0be44d247749f3c..c1b255842c1eda65278862aff49dfbd63bca8e5c 100644 (file)
@@ -7,10 +7,10 @@ package imports
 import "io"
 
 import (
-       _       "io"
+       _ "io"
 )
 
-import _       "io"
+import _ "io"
 
 import (
        "io"
@@ -20,40 +20,40 @@ import (
 
 import (
        "io"
-       aLongRename     "io"
+       aLongRename "io"
 
-       b       "io"
+       b "io"
 )
 
 import (
        "unrenamed"
-       renamed "renameMe"
-       .       "io"
-       _       "io"
+       renamed "renameMe"
+       . "io"
+       _ "io"
        "io"
-       .       "os"
+       . "os"
 )
 
 // no newlines between consecutive single imports, but
 // respect extra line breaks in the source (at most one empty line)
-import _       "io"
-import _       "io"
-import _       "io"
+import _ "io"
+import _ "io"
+import _ "io"
 
-import _       "os"
-import _       "os"
-import _       "os"
+import _ "os"
+import _ "os"
+import _ "os"
 
 
-import _       "fmt"
-import _       "fmt"
-import _       "fmt"
+import _ "fmt"
+import _ "fmt"
+import _ "fmt"
 
 import "foo"   // a comment
 import "bar"   // a comment
 
 import (
-       _       "foo"
+       _ "foo"
        // a comment
        "bar"
        "foo"   // a comment
@@ -63,17 +63,17 @@ import (
 // comments + renames
 import (
        "unrenamed"     // a comment
-       renamed         "renameMe"
-       .               "io"            /* a comment */
-       _               "io/ioutil"     // a comment
+       renamed "renameMe"
+       . "io"          /* a comment */
+       _ "io/ioutil"   // a comment
        "io"            // testing alignment
-       .               "os"
+       . "os"
        // a comment
 )
 
 // a case that caused problems in the past (comment placement)
 import (
-       .       "fmt"
+       . "fmt"
        "io"
        "malloc"        // for the malloc count test only
        "math"
@@ -81,9 +81,38 @@ import (
        "testing"
 )
 
+// more import examples
+import (
+       "xxx"
+       "much longer name"      // comment
+       "short name"            // comment
+)
+
+import (
+       _ "xxx"
+       "much longer name"      // comment
+)
+
+import (
+       mymath "math"
+       "/foo/bar/long_package_path"    // a comment
+)
+
+import (
+       "package_a"     // comment
+       "package_b"
+       my_better_c "package_c" // comment
+       "package_d"             // comment
+       my_e "package_e"        // comment
+
+       "package_a"     // comment
+       "package_bb"
+       "package_ccc"   // comment
+       "package_dddd"  // comment
+)
 
 // at least one empty line between declarations of different kind
-import _       "io"
+import _ "io"
 
 var _ int
 
index c826462f9dce05b88351552993868f8913d822c8..c8b37e12ba49e264fd4a406f7530020f9fe596c6 100644 (file)
@@ -81,6 +81,35 @@ import (
        "testing"
 )
 
+// more import examples
+import (
+       "xxx"
+       "much longer name" // comment
+       "short name" // comment
+)
+
+import (
+       _ "xxx"
+       "much longer name" // comment
+)
+
+import (
+       mymath "math"
+       "/foo/bar/long_package_path" // a comment
+)
+
+import (
+       "package_a" // comment
+       "package_b"
+       my_better_c "package_c" // comment
+       "package_d" // comment
+       my_e "package_e" // comment
+
+       "package_a"    // comment
+       "package_bb"
+       "package_ccc"  // comment
+       "package_dddd" // comment
+)
 
 // at least one empty line between declarations of different kind
 import _ "io"