Browse Source

protoc-gen-go: put imports in a single import() block (#707)

Put all the imports into a single block.

Before:

	import proto "github.com/golang/protobuf/proto"
	import fmt "fmt"
	import math "math"

After:

	import (
		fmt "fmt"
		proto "github.com/golang/protobuf/proto"
		math "math"
	)

Sort imports using ast.SortImports rather than doing our own sorting,
ensuring consistency with gofmt.

This is a trivial change, but allows for identical output from this
version of the generator and one which uses astutil.AddNamedImport to
patch imports into the AST.
Damien Neil 7 years ago
parent
commit
a47340a8e4
37 changed files with 222 additions and 158 deletions
  1. 11 9
      conformance/internal/conformance_proto/conformance.pb.go
  2. 5 3
      jsonpb/jsonpb_test_proto/more_test_objects.pb.go
  3. 10 8
      jsonpb/jsonpb_test_proto/test_objects.pb.go
  4. 7 5
      proto/proto3_proto/proto3.pb.go
  5. 5 3
      proto/test_proto/test.pb.go
  6. 5 3
      protoc-gen-go/descriptor/descriptor.pb.go
  7. 18 26
      protoc-gen-go/generator/generator.go
  8. 5 3
      protoc-gen-go/testdata/deprecated/deprecated.pb.go
  9. 5 3
      protoc-gen-go/testdata/extension_base/extension_base.pb.go
  10. 5 3
      protoc-gen-go/testdata/extension_extra/extension_extra.pb.go
  11. 7 5
      protoc-gen-go/testdata/extension_user/extension_user.pb.go
  12. 5 3
      protoc-gen-go/testdata/grpc/grpc.pb.go
  13. 6 4
      protoc-gen-go/testdata/import_public/a.pb.go
  14. 6 4
      protoc-gen-go/testdata/import_public/b.pb.go
  15. 5 3
      protoc-gen-go/testdata/import_public/sub/a.pb.go
  16. 5 3
      protoc-gen-go/testdata/import_public/sub/b.pb.go
  17. 5 3
      protoc-gen-go/testdata/imports/fmt/m.pb.go
  18. 5 3
      protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
  19. 5 3
      protoc-gen-go/testdata/imports/test_a_1/m2.pb.go
  20. 5 3
      protoc-gen-go/testdata/imports/test_a_2/m3.pb.go
  21. 5 3
      protoc-gen-go/testdata/imports/test_a_2/m4.pb.go
  22. 5 3
      protoc-gen-go/testdata/imports/test_b_1/m1.pb.go
  23. 5 3
      protoc-gen-go/testdata/imports/test_b_1/m2.pb.go
  24. 6 4
      protoc-gen-go/testdata/imports/test_import_a1m1.pb.go
  25. 6 4
      protoc-gen-go/testdata/imports/test_import_a1m2.pb.go
  26. 9 7
      protoc-gen-go/testdata/imports/test_import_all.pb.go
  27. 5 3
      protoc-gen-go/testdata/multi/multi1.pb.go
  28. 5 3
      protoc-gen-go/testdata/multi/multi2.pb.go
  29. 5 3
      protoc-gen-go/testdata/multi/multi3.pb.go
  30. 6 4
      protoc-gen-go/testdata/my_test/test.pb.go
  31. 5 3
      protoc-gen-go/testdata/proto3/proto3.pb.go
  32. 5 3
      ptypes/any/any.pb.go
  33. 5 3
      ptypes/duration/duration.pb.go
  34. 5 3
      ptypes/empty/empty.pb.go
  35. 5 3
      ptypes/struct/struct.pb.go
  36. 5 3
      ptypes/timestamp/timestamp.pb.go
  37. 5 3
      ptypes/wrappers/wrappers.pb.go

+ 11 - 9
conformance/internal/conformance_proto/conformance.pb.go

@@ -3,15 +3,17 @@
 
 package conformance
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import any "github.com/golang/protobuf/ptypes/any"
-import duration "github.com/golang/protobuf/ptypes/duration"
-import _struct "github.com/golang/protobuf/ptypes/struct"
-import timestamp "github.com/golang/protobuf/ptypes/timestamp"
-import wrappers "github.com/golang/protobuf/ptypes/wrappers"
-import field_mask "google.golang.org/genproto/protobuf/field_mask"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	any "github.com/golang/protobuf/ptypes/any"
+	duration "github.com/golang/protobuf/ptypes/duration"
+	_struct "github.com/golang/protobuf/ptypes/struct"
+	timestamp "github.com/golang/protobuf/ptypes/timestamp"
+	wrappers "github.com/golang/protobuf/ptypes/wrappers"
+	field_mask "google.golang.org/genproto/protobuf/field_mask"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
jsonpb/jsonpb_test_proto/more_test_objects.pb.go

@@ -3,9 +3,11 @@
 
 package jsonpb
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 10 - 8
jsonpb/jsonpb_test_proto/test_objects.pb.go

@@ -3,14 +3,16 @@
 
 package jsonpb
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import any "github.com/golang/protobuf/ptypes/any"
-import duration "github.com/golang/protobuf/ptypes/duration"
-import _struct "github.com/golang/protobuf/ptypes/struct"
-import timestamp "github.com/golang/protobuf/ptypes/timestamp"
-import wrappers "github.com/golang/protobuf/ptypes/wrappers"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	any "github.com/golang/protobuf/ptypes/any"
+	duration "github.com/golang/protobuf/ptypes/duration"
+	_struct "github.com/golang/protobuf/ptypes/struct"
+	timestamp "github.com/golang/protobuf/ptypes/timestamp"
+	wrappers "github.com/golang/protobuf/ptypes/wrappers"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 7 - 5
proto/proto3_proto/proto3.pb.go

@@ -3,11 +3,13 @@
 
 package proto3_proto
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import test_proto "github.com/golang/protobuf/proto/test_proto"
-import any "github.com/golang/protobuf/ptypes/any"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	test_proto "github.com/golang/protobuf/proto/test_proto"
+	any "github.com/golang/protobuf/ptypes/any"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
proto/test_proto/test.pb.go

@@ -3,9 +3,11 @@
 
 package test_proto
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/descriptor/descriptor.pb.go

@@ -3,9 +3,11 @@
 
 package descriptor
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 18 - 26
protoc-gen-go/generator/generator.go

@@ -43,6 +43,7 @@ import (
 	"crypto/sha256"
 	"encoding/hex"
 	"fmt"
+	"go/ast"
 	"go/build"
 	"go/parser"
 	"go/printer"
@@ -1165,7 +1166,7 @@ func (g *Generator) generate(file *FileDescriptor) {
 		// make a copy independent of g; we'll need it after Reset.
 		original = append([]byte(nil), original...)
 	}
-	ast, err := parser.ParseFile(fset, "", original, parser.ParseComments)
+	fileAST, err := parser.ParseFile(fset, "", original, parser.ParseComments)
 	if err != nil {
 		// Print out the bad code with line numbers.
 		// This should never happen in practice, but it can while changing generated code,
@@ -1177,8 +1178,9 @@ func (g *Generator) generate(file *FileDescriptor) {
 		}
 		g.Fail("bad Go source code was generated:", err.Error(), "\n"+src.String())
 	}
+	ast.SortImports(fset, fileAST)
 	g.Reset()
-	err = (&printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}).Fprint(g, fset, ast)
+	err = (&printer.Config{Mode: printer.TabIndent | printer.UseSpaces, Tabwidth: 8}).Fprint(g, fset, fileAST)
 	if err != nil {
 		g.Fail("generated Go source code could not be reformatted:", err.Error())
 	}
@@ -1276,17 +1278,14 @@ func (g *Generator) weak(i int32) bool {
 
 // Generate the imports
 func (g *Generator) generateImports() {
+	g.P("import (")
 	// We almost always need a proto import.  Rather than computing when we
 	// do, which is tricky when there's a plugin, just import it and
 	// reference it later. The same argument applies to the fmt and math packages.
-	g.P("import "+g.Pkg["proto"]+" ", GoImportPath(g.ImportPrefix)+"github.com/golang/protobuf/proto")
-	g.P("import " + g.Pkg["fmt"] + ` "fmt"`)
-	g.P("import " + g.Pkg["math"] + ` "math"`)
-	var (
-		imports       = make(map[GoImportPath]bool)
-		strongImports = make(map[GoImportPath]bool)
-		importPaths   []string
-	)
+	g.P(g.Pkg["proto"]+" ", GoImportPath(g.ImportPrefix)+"github.com/golang/protobuf/proto")
+	g.P(g.Pkg["fmt"] + ` "fmt"`)
+	g.P(g.Pkg["math"] + ` "math"`)
+	imports := make(map[GoImportPath]bool)
 	for i, s := range g.file.Dependency {
 		fd := g.fileByName(s)
 		importPath := fd.importPath
@@ -1294,32 +1293,25 @@ func (g *Generator) generateImports() {
 		if importPath == g.file.importPath {
 			continue
 		}
-		if !imports[importPath] {
-			importPaths = append(importPaths, string(importPath))
-		}
-		imports[importPath] = true
-		if !g.weak(int32(i)) {
-			strongImports[importPath] = true
+		// Do not import weak imports.
+		if g.weak(int32(i)) {
+			continue
 		}
-	}
-	sort.Strings(importPaths)
-	for i := range importPaths {
-		importPath := GoImportPath(importPaths[i])
-		packageName := g.GoPackageName(importPath)
-		fullPath := GoImportPath(g.ImportPrefix) + importPath
-		// Skip weak imports.
-		if !strongImports[importPath] {
-			g.P("// skipping weak import ", packageName, " ", fullPath)
+		// Do not import a package twice.
+		if imports[importPath] {
 			continue
 		}
+		imports[importPath] = true
 		// We need to import all the dependencies, even if we don't reference them,
 		// because other code and tools depend on having the full transitive closure
 		// of protocol buffer types in the binary.
+		packageName := g.GoPackageName(importPath)
 		if _, ok := g.usedPackages[importPath]; !ok {
 			packageName = "_"
 		}
-		g.P("import ", packageName, " ", fullPath)
+		g.P(packageName, " ", GoImportPath(g.ImportPrefix)+importPath)
 	}
+	g.P(")")
 	g.P()
 	// TODO: may need to worry about uniqueness across plugins
 	for _, p := range plugins {

+ 5 - 3
protoc-gen-go/testdata/deprecated/deprecated.pb.go

@@ -7,9 +7,11 @@ package deprecated
 package deprecated contains only deprecated messages and services.
 */
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 import (
 	context "golang.org/x/net/context"

+ 5 - 3
protoc-gen-go/testdata/extension_base/extension_base.pb.go

@@ -3,9 +3,11 @@
 
 package extension_base
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/extension_extra/extension_extra.pb.go

@@ -3,9 +3,11 @@
 
 package extension_extra
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 7 - 5
protoc-gen-go/testdata/extension_user/extension_user.pb.go

@@ -3,11 +3,13 @@
 
 package extension_user
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import extension_base "github.com/golang/protobuf/protoc-gen-go/testdata/extension_base"
-import extension_extra "github.com/golang/protobuf/protoc-gen-go/testdata/extension_extra"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	extension_base "github.com/golang/protobuf/protoc-gen-go/testdata/extension_base"
+	extension_extra "github.com/golang/protobuf/protoc-gen-go/testdata/extension_extra"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/grpc/grpc.pb.go

@@ -3,9 +3,11 @@
 
 package testing
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 import (
 	context "golang.org/x/net/context"

+ 6 - 4
protoc-gen-go/testdata/import_public/a.pb.go

@@ -3,10 +3,12 @@
 
 package import_public
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import sub "github.com/golang/protobuf/protoc-gen-go/testdata/import_public/sub"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	sub "github.com/golang/protobuf/protoc-gen-go/testdata/import_public/sub"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 6 - 4
protoc-gen-go/testdata/import_public/b.pb.go

@@ -3,10 +3,12 @@
 
 package import_public
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import sub "github.com/golang/protobuf/protoc-gen-go/testdata/import_public/sub"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	sub "github.com/golang/protobuf/protoc-gen-go/testdata/import_public/sub"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/import_public/sub/a.pb.go

@@ -3,9 +3,11 @@
 
 package sub
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/import_public/sub/b.pb.go

@@ -3,9 +3,11 @@
 
 package sub
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/fmt/m.pb.go

@@ -3,9 +3,11 @@
 
 package fmt
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/test_a_1/m1.pb.go

@@ -3,9 +3,11 @@
 
 package test_a_1
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/test_a_1/m2.pb.go

@@ -3,9 +3,11 @@
 
 package test_a_1
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/test_a_2/m3.pb.go

@@ -3,9 +3,11 @@
 
 package test_a_2
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/test_a_2/m4.pb.go

@@ -3,9 +3,11 @@
 
 package test_a_2
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/test_b_1/m1.pb.go

@@ -3,9 +3,11 @@
 
 package beta
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/imports/test_b_1/m2.pb.go

@@ -3,9 +3,11 @@
 
 package beta
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 6 - 4
protoc-gen-go/testdata/imports/test_import_a1m1.pb.go

@@ -3,10 +3,12 @@
 
 package imports
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 6 - 4
protoc-gen-go/testdata/imports/test_import_a1m2.pb.go

@@ -3,10 +3,12 @@
 
 package imports
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 9 - 7
protoc-gen-go/testdata/imports/test_import_all.pb.go

@@ -3,13 +3,15 @@
 
 package imports
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import fmt1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt"
-import test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
-import test_a_2 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2"
-import test_b_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_b_1"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	fmt1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/fmt"
+	test_a_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_1"
+	test_a_2 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_a_2"
+	test_b_1 "github.com/golang/protobuf/protoc-gen-go/testdata/imports/test_b_1"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/multi/multi1.pb.go

@@ -3,9 +3,11 @@
 
 package multitest
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/multi/multi2.pb.go

@@ -3,9 +3,11 @@
 
 package multitest
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/multi/multi3.pb.go

@@ -3,9 +3,11 @@
 
 package multitest
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 6 - 4
protoc-gen-go/testdata/my_test/test.pb.go

@@ -7,10 +7,12 @@ package test
 This package holds interesting messages.
 */
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import _ "github.com/golang/protobuf/protoc-gen-go/testdata/multi"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	_ "github.com/golang/protobuf/protoc-gen-go/testdata/multi"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
protoc-gen-go/testdata/proto3/proto3.pb.go

@@ -3,9 +3,11 @@
 
 package proto3
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
ptypes/any/any.pb.go

@@ -3,9 +3,11 @@
 
 package any
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
ptypes/duration/duration.pb.go

@@ -3,9 +3,11 @@
 
 package duration
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
ptypes/empty/empty.pb.go

@@ -3,9 +3,11 @@
 
 package empty
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
ptypes/struct/struct.pb.go

@@ -3,9 +3,11 @@
 
 package structpb
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
ptypes/timestamp/timestamp.pb.go

@@ -3,9 +3,11 @@
 
 package timestamp
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal

+ 5 - 3
ptypes/wrappers/wrappers.pb.go

@@ -3,9 +3,11 @@
 
 package wrappers
 
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
+import (
+	fmt "fmt"
+	proto "github.com/golang/protobuf/proto"
+	math "math"
+)
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal