瀏覽代碼

Various code-cleanup

remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 7 年之前
父節點
當前提交
f23c00d870
共有 100 個文件被更改,包括 154 次插入168 次删除
  1. 2 2
      api/common.go
  2. 1 1
      api/common_unix.go
  3. 1 1
      api/server/router/build/build_routes.go
  4. 1 2
      api/server/server_test.go
  5. 1 1
      api/types/client.go
  6. 1 1
      builder/builder.go
  7. 1 1
      builder/dockerfile/buildargs.go
  8. 1 1
      builder/dockerfile/builder.go
  9. 0 1
      builder/dockerfile/instructions/commands.go
  10. 1 1
      builder/dockerfile/instructions/support_test.go
  11. 1 2
      builder/dockerfile/parser/parser.go
  12. 1 1
      builder/dockerfile/shell/lex_test.go
  13. 1 1
      builder/remotecontext/tarsum.go
  14. 2 2
      cli/cobra.go
  15. 1 2
      client/container_wait_test.go
  16. 0 1
      client/errors.go
  17. 1 2
      client/image_save_test.go
  18. 1 2
      client/node_remove.go
  19. 1 2
      client/node_remove_test.go
  20. 1 2
      client/plugin_remove_test.go
  21. 1 1
      client/request_test.go
  22. 1 1
      client/service_create.go
  23. 1 1
      cmd/dockerd/config_unix.go
  24. 1 1
      cmd/dockerd/metrics.go
  25. 1 1
      container/view.go
  26. 1 1
      daemon/cluster/convert/container.go
  27. 1 1
      daemon/cluster/executor/container/container_test.go
  28. 1 1
      daemon/config/config_unix.go
  29. 1 1
      daemon/config/config_unix_test.go
  30. 3 3
      daemon/daemon_unix.go
  31. 1 1
      daemon/exec.go
  32. 2 2
      daemon/graphdriver/aufs/dirs.go
  33. 3 3
      daemon/graphdriver/devmapper/deviceset.go
  34. 1 1
      daemon/graphdriver/devmapper/driver.go
  35. 1 1
      daemon/graphdriver/graphtest/graphtest_unix.go
  36. 1 1
      daemon/graphdriver/graphtest/testutil.go
  37. 1 1
      daemon/graphdriver/vfs/driver.go
  38. 1 1
      daemon/graphdriver/zfs/zfs.go
  39. 2 2
      daemon/images/image_delete.go
  40. 1 1
      daemon/images/image_prune.go
  41. 1 1
      daemon/images/locals.go
  42. 1 1
      daemon/logger/adapter.go
  43. 1 1
      daemon/logger/awslogs/cloudwatchlogs_test.go
  44. 1 1
      daemon/logger/factory.go
  45. 1 2
      daemon/logger/gcplogs/gcplogging.go
  46. 1 1
      daemon/logger/jsonfilelog/jsonfilelog.go
  47. 1 1
      daemon/logger/loggerutils/multireader/multireader_test.go
  48. 1 1
      daemon/metrics.go
  49. 2 2
      daemon/metrics_unix.go
  50. 1 1
      daemon/oci_linux.go
  51. 1 1
      daemon/reload_test.go
  52. 1 1
      daemon/update_linux.go
  53. 1 1
      distribution/errors_test.go
  54. 1 1
      distribution/pull_v2.go
  55. 1 1
      distribution/push_v2.go
  56. 8 8
      dockerversion/version_lib.go
  57. 2 2
      hack/integration-cli-on-swarm/agent/master/set_test.go
  58. 1 1
      image/tarexport/load.go
  59. 1 1
      integration-cli/docker_api_build_test.go
  60. 2 2
      integration-cli/docker_api_network_test.go
  61. 3 3
      integration-cli/docker_cli_build_test.go
  62. 1 1
      integration-cli/docker_cli_build_unix_test.go
  63. 8 8
      integration-cli/docker_cli_create_test.go
  64. 5 6
      integration-cli/docker_cli_daemon_test.go
  65. 1 1
      integration-cli/docker_cli_exec_test.go
  66. 6 6
      integration-cli/docker_cli_network_unix_test.go
  67. 2 2
      integration-cli/docker_cli_ps_test.go
  68. 3 3
      integration-cli/docker_cli_pull_local_test.go
  69. 1 1
      integration-cli/docker_cli_push_test.go
  70. 3 3
      integration-cli/docker_cli_save_load_test.go
  71. 1 1
      integration-cli/docker_cli_sni_test.go
  72. 0 1
      integration-cli/environment/environment.go
  73. 2 2
      integration-cli/utils_test.go
  74. 1 1
      integration/build/build_test.go
  75. 1 1
      integration/config/config_test.go
  76. 2 2
      integration/container/pause_test.go
  77. 1 1
      integration/container/ps_test.go
  78. 2 2
      integration/network/service_test.go
  79. 1 1
      integration/secret/secret_test.go
  80. 6 6
      internal/test/environment/protect.go
  81. 1 1
      libcontainerd/client_daemon_linux.go
  82. 1 1
      libcontainerd/types_linux.go
  83. 1 2
      migrate/v1/migratev1.go
  84. 1 1
      oci/devices_linux.go
  85. 1 1
      oci/namespaces.go
  86. 1 1
      opts/address_pools.go
  87. 5 5
      opts/opts.go
  88. 1 1
      pkg/archive/changes_posix_test.go
  89. 1 1
      pkg/archive/time_linux.go
  90. 0 1
      pkg/broadcaster/unbuffered_test.go
  91. 1 1
      pkg/devicemapper/devmapper_wrapper.go
  92. 2 2
      pkg/idtools/idtools.go
  93. 2 2
      pkg/jsonmessage/jsonmessage.go
  94. 4 4
      pkg/pubsub/publisher_test.go
  95. 1 1
      pkg/signal/signal.go
  96. 1 1
      pkg/term/windows/windows.go
  97. 1 1
      pkg/truncindex/truncindex_test.go
  98. 1 1
      plugin/backend_linux.go
  99. 1 1
      plugin/defs.go
  100. 1 1
      plugin/executor/containerd/containerd_test.go

+ 2 - 2
api/common.go

@@ -3,9 +3,9 @@ package api // import "github.com/docker/docker/api"
 // Common constants for daemon and client.
 const (
 	// DefaultVersion of Current REST API
-	DefaultVersion string = "1.37"
+	DefaultVersion = "1.37"
 
 	// NoBaseImageSpecifier is the symbol used by the FROM
 	// command to specify that no base image is to be used.
-	NoBaseImageSpecifier string = "scratch"
+	NoBaseImageSpecifier = "scratch"
 )

+ 1 - 1
api/common_unix.go

@@ -3,4 +3,4 @@
 package api // import "github.com/docker/docker/api"
 
 // MinVersion represents Minimum REST API version supported
-const MinVersion string = "1.12"
+const MinVersion = "1.12"

+ 1 - 1
api/server/router/build/build_routes.go

@@ -23,7 +23,7 @@ import (
 	"github.com/docker/docker/pkg/progress"
 	"github.com/docker/docker/pkg/streamformatter"
 	"github.com/docker/docker/pkg/system"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 )

+ 1 - 2
api/server/server_test.go

@@ -1,13 +1,12 @@
 package server // import "github.com/docker/docker/api/server"
 
 import (
+	"context"
 	"net/http"
 	"net/http/httptest"
 	"strings"
 	"testing"
 
-	"context"
-
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api/server/httputils"
 	"github.com/docker/docker/api/server/middleware"

+ 1 - 1
api/types/client.go

@@ -7,7 +7,7 @@ import (
 
 	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/api/types/filters"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 )
 
 // CheckpointCreateOptions holds parameters to create a checkpoint from a container

+ 1 - 1
builder/builder.go

@@ -19,7 +19,7 @@ import (
 
 const (
 	// DefaultDockerfileName is the Default filename with Docker commands, read by docker build
-	DefaultDockerfileName string = "Dockerfile"
+	DefaultDockerfileName = "Dockerfile"
 )
 
 // Source defines a location that can be used as a source for the ADD/COPY

+ 1 - 1
builder/dockerfile/buildargs.go

@@ -69,7 +69,7 @@ func (b *BuildArgs) MergeReferencedArgs(other *BuildArgs) {
 // WarnOnUnusedBuildArgs checks if there are any leftover build-args that were
 // passed but not consumed during build. Print a warning, if there are any.
 func (b *BuildArgs) WarnOnUnusedBuildArgs(out io.Writer) {
-	leftoverArgs := []string{}
+	var leftoverArgs []string
 	for arg := range b.argsFromOptions {
 		_, isReferenced := b.referencedArgs[arg]
 		_, isBuiltin := builtinAllowedBuildArgs[arg]

+ 1 - 1
builder/dockerfile/builder.go

@@ -387,7 +387,7 @@ func BuildFromConfig(config *container.Config, changes []string, os string) (*co
 	b.Stderr = ioutil.Discard
 	b.disableCommit = true
 
-	commands := []instructions.Command{}
+	var commands []instructions.Command
 	for _, n := range dockerfile.AST.Children {
 		cmd, err := instructions.ParseCommand(n)
 		if err != nil {

+ 0 - 1
builder/dockerfile/instructions/commands.go

@@ -2,7 +2,6 @@ package instructions // import "github.com/docker/docker/builder/dockerfile/inst
 
 import (
 	"errors"
-
 	"strings"
 
 	"github.com/docker/docker/api/types/container"

+ 1 - 1
builder/dockerfile/instructions/support_test.go

@@ -10,7 +10,7 @@ type testCase struct {
 }
 
 func initTestCases() []testCase {
-	testCases := []testCase{}
+	var testCases []testCase
 
 	testCases = append(testCases, testCase{
 		name:       "empty args",

+ 1 - 2
builder/dockerfile/parser/parser.go

@@ -262,8 +262,7 @@ func Parse(rwc io.Reader) (*Result, error) {
 		}
 
 		if hasEmptyContinuationLine {
-			warning := "[WARNING]: Empty continuation line found in:\n    " + line
-			warnings = append(warnings, warning)
+			warnings = append(warnings, "[WARNING]: Empty continuation line found in:\n    "+line)
 		}
 
 		child, err := newNodeFromLine(line, d)

+ 1 - 1
builder/dockerfile/shell/lex_test.go

@@ -71,8 +71,8 @@ func TestShellParser4Words(t *testing.T) {
 	}
 	defer file.Close()
 
+	var envs []string
 	shlex := NewLex('\\')
-	envs := []string{}
 	scanner := bufio.NewScanner(file)
 	lineNum := 0
 	for scanner.Scan() {

+ 1 - 1
builder/remotecontext/tarsum.go

@@ -6,7 +6,7 @@ import (
 
 	"github.com/docker/docker/pkg/containerfs"
 	iradix "github.com/hashicorp/go-immutable-radix"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	"github.com/pkg/errors"
 	"github.com/tonistiigi/fsutil"
 )

+ 2 - 2
cli/cobra.go

@@ -51,7 +51,7 @@ func hasManagementSubCommands(cmd *cobra.Command) bool {
 }
 
 func operationSubCommands(cmd *cobra.Command) []*cobra.Command {
-	cmds := []*cobra.Command{}
+	var cmds []*cobra.Command
 	for _, sub := range cmd.Commands() {
 		if sub.IsAvailableCommand() && !sub.HasSubCommands() {
 			cmds = append(cmds, sub)
@@ -69,7 +69,7 @@ func wrappedFlagUsages(cmd *cobra.Command) string {
 }
 
 func managementSubCommands(cmd *cobra.Command) []*cobra.Command {
-	cmds := []*cobra.Command{}
+	var cmds []*cobra.Command
 	for _, sub := range cmd.Commands() {
 		if sub.IsAvailableCommand() && sub.HasSubCommands() {
 			cmds = append(cmds, sub)

+ 1 - 2
client/container_wait_test.go

@@ -2,6 +2,7 @@ package client // import "github.com/docker/docker/client"
 
 import (
 	"bytes"
+	"context"
 	"encoding/json"
 	"fmt"
 	"io/ioutil"
@@ -11,8 +12,6 @@ import (
 	"testing"
 	"time"
 
-	"context"
-
 	"github.com/docker/docker/api/types/container"
 )
 

+ 0 - 1
client/errors.go

@@ -2,7 +2,6 @@ package client // import "github.com/docker/docker/client"
 
 import (
 	"fmt"
-
 	"net/http"
 
 	"github.com/docker/docker/api/types/versions"

+ 1 - 2
client/image_save_test.go

@@ -7,9 +7,8 @@ import (
 	"io/ioutil"
 	"net/http"
 	"reflect"
-	"testing"
-
 	"strings"
+	"testing"
 )
 
 func TestImageSaveError(t *testing.T) {

+ 1 - 2
client/node_remove.go

@@ -1,9 +1,8 @@
 package client // import "github.com/docker/docker/client"
 
 import (
-	"net/url"
-
 	"context"
+	"net/url"
 
 	"github.com/docker/docker/api/types"
 )

+ 1 - 2
client/node_remove_test.go

@@ -2,14 +2,13 @@ package client // import "github.com/docker/docker/client"
 
 import (
 	"bytes"
+	"context"
 	"fmt"
 	"io/ioutil"
 	"net/http"
 	"strings"
 	"testing"
 
-	"context"
-
 	"github.com/docker/docker/api/types"
 )
 

+ 1 - 2
client/plugin_remove_test.go

@@ -2,14 +2,13 @@ package client // import "github.com/docker/docker/client"
 
 import (
 	"bytes"
+	"context"
 	"fmt"
 	"io/ioutil"
 	"net/http"
 	"strings"
 	"testing"
 
-	"context"
-
 	"github.com/docker/docker/api/types"
 )
 

+ 1 - 1
client/request_test.go

@@ -61,7 +61,7 @@ func TestSetHostHeader(t *testing.T) {
 				}
 				return &http.Response{
 					StatusCode: http.StatusOK,
-					Body:       ioutil.NopCloser(bytes.NewReader(([]byte("")))),
+					Body:       ioutil.NopCloser(bytes.NewReader([]byte(""))),
 				}, nil
 			}),
 

+ 1 - 1
client/service_create.go

@@ -9,7 +9,7 @@ import (
 	"github.com/docker/distribution/reference"
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/swarm"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	"github.com/pkg/errors"
 )
 

+ 1 - 1
cmd/dockerd/config_unix.go

@@ -5,7 +5,7 @@ package main
 import (
 	"github.com/docker/docker/daemon/config"
 	"github.com/docker/docker/opts"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/spf13/pflag"
 )
 

+ 1 - 1
cmd/dockerd/metrics.go

@@ -4,7 +4,7 @@ import (
 	"net"
 	"net/http"
 
-	metrics "github.com/docker/go-metrics"
+	"github.com/docker/go-metrics"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
container/view.go

@@ -340,7 +340,7 @@ func (v *memdbView) transform(container *Container) *Snapshot {
 	}
 
 	if len(container.Args) > 0 {
-		args := []string{}
+		var args []string
 		for _, arg := range container.Args {
 			if strings.Contains(arg, " ") {
 				args = append(args, fmt.Sprintf("'%s'", arg))

+ 1 - 1
daemon/cluster/convert/container.go

@@ -5,7 +5,7 @@ import (
 	"fmt"
 	"strings"
 
-	container "github.com/docker/docker/api/types/container"
+	"github.com/docker/docker/api/types/container"
 	mounttypes "github.com/docker/docker/api/types/mount"
 	types "github.com/docker/docker/api/types/swarm"
 	swarmapi "github.com/docker/swarmkit/api"

+ 1 - 1
daemon/cluster/executor/container/container_test.go

@@ -3,7 +3,7 @@ package container // import "github.com/docker/docker/daemon/cluster/executor/co
 import (
 	"testing"
 
-	container "github.com/docker/docker/api/types/container"
+	"github.com/docker/docker/api/types/container"
 	swarmapi "github.com/docker/swarmkit/api"
 	"github.com/gotestyourself/gotestyourself/assert"
 )

+ 1 - 1
daemon/config/config_unix.go

@@ -7,7 +7,7 @@ import (
 
 	containertypes "github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/opts"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 )
 
 const (

+ 1 - 1
daemon/config/config_unix_test.go

@@ -6,7 +6,7 @@ import (
 	"testing"
 
 	"github.com/docker/docker/opts"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/gotestyourself/gotestyourself/assert"
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
 	"github.com/gotestyourself/gotestyourself/fs"

+ 3 - 3
daemon/daemon_unix.go

@@ -43,7 +43,7 @@ import (
 	lntypes "github.com/docker/libnetwork/types"
 	"github.com/opencontainers/runc/libcontainer/cgroups"
 	rsystem "github.com/opencontainers/runc/libcontainer/system"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
@@ -67,8 +67,8 @@ const (
 	// It's not kernel limit, we want this 4M limit to supply a reasonable functional container
 	linuxMinMemory = 4194304
 	// constants for remapped root settings
-	defaultIDSpecifier string = "default"
-	defaultRemappedID  string = "dockremap"
+	defaultIDSpecifier = "default"
+	defaultRemappedID  = "dockremap"
 
 	// constant for cgroup drivers
 	cgroupFsDriver      = "cgroupfs"

+ 1 - 1
daemon/exec.go

@@ -16,7 +16,7 @@ import (
 	"github.com/docker/docker/pkg/pools"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/term"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 )

+ 2 - 2
daemon/graphdriver/aufs/dirs.go

@@ -15,7 +15,7 @@ func loadIds(root string) ([]string, error) {
 	if err != nil {
 		return nil, err
 	}
-	out := []string{}
+	var out []string
 	for _, d := range dirs {
 		if !d.IsDir() {
 			out = append(out, d.Name())
@@ -36,7 +36,7 @@ func getParentIDs(root, id string) ([]string, error) {
 	}
 	defer f.Close()
 
-	out := []string{}
+	var out []string
 	s := bufio.NewScanner(f)
 
 	for s.Scan() {

+ 3 - 3
daemon/graphdriver/devmapper/deviceset.go

@@ -27,7 +27,7 @@ import (
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers/kernel"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
@@ -50,8 +50,8 @@ var (
 	lvmSetupConfigForce          bool
 )
 
-const deviceSetMetaFile string = "deviceset-metadata"
-const transactionMetaFile string = "transaction-metadata"
+const deviceSetMetaFile = "deviceset-metadata"
+const transactionMetaFile = "transaction-metadata"
 
 type transaction struct {
 	OpenTransactionID uint64 `json:"open_transaction_id"`

+ 1 - 1
daemon/graphdriver/devmapper/driver.go

@@ -15,7 +15,7 @@ import (
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/locker"
 	"github.com/docker/docker/pkg/mount"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sys/unix"

+ 1 - 1
daemon/graphdriver/graphtest/graphtest_unix.go

@@ -15,7 +15,7 @@ import (
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver/quota"
 	"github.com/docker/docker/pkg/stringid"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/gotestyourself/gotestyourself/assert"
 	is "github.com/gotestyourself/gotestyourself/assert/cmp"
 	"golang.org/x/sys/unix"

+ 1 - 1
daemon/graphdriver/graphtest/testutil.go

@@ -148,7 +148,7 @@ func changeManyFiles(drv graphdriver.Driver, layer string, count int, seed int64
 	}
 	defer drv.Put(layer)
 
-	changes := []archive.Change{}
+	var changes []archive.Change
 	for i := 0; i < count; i += 100 {
 		archiveRoot := fmt.Sprintf("/directory-%d", i)
 		if err := root.MkdirAll(root.Join(root.Path(), archiveRoot), 0755); err != nil {

+ 1 - 1
daemon/graphdriver/vfs/driver.go

@@ -10,7 +10,7 @@ import (
 	"github.com/docker/docker/pkg/containerfs"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/system"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/opencontainers/selinux/go-selinux/label"
 )
 

+ 1 - 1
daemon/graphdriver/zfs/zfs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/parsers"
-	zfs "github.com/mistifyio/go-zfs"
+	"github.com/mistifyio/go-zfs"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sys/unix"

+ 2 - 2
daemon/images/image_delete.go

@@ -18,7 +18,7 @@ import (
 type conflictType int
 
 const (
-	conflictDependentChild conflictType = (1 << iota)
+	conflictDependentChild conflictType = 1 << iota
 	conflictRunningContainer
 	conflictActiveReference
 	conflictStoppedContainer
@@ -126,7 +126,7 @@ func (i *ImageService) ImageDelete(imageRef string, force, prune bool) ([]types.
 			}
 			if !foundRepoTagRef {
 				// Remove canonical references from same repository
-				remainingRefs := []reference.Named{}
+				var remainingRefs []reference.Named
 				for _, repoRef := range repoRefs {
 					if _, repoRefIsCanonical := repoRef.(reference.Canonical); repoRefIsCanonical && parsedRef.Name() == repoRef.Name() {
 						if _, err := i.removeImageRef(repoRef); err != nil {

+ 1 - 1
daemon/images/image_prune.go

@@ -13,7 +13,7 @@ import (
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/layer"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
daemon/images/locals.go

@@ -3,7 +3,7 @@ package images // import "github.com/docker/docker/daemon/images"
 import (
 	"fmt"
 
-	metrics "github.com/docker/go-metrics"
+	"github.com/docker/go-metrics"
 )
 
 type invalidFilter struct {

+ 1 - 1
daemon/logger/adapter.go

@@ -37,7 +37,7 @@ func (a *pluginAdapter) Log(msg *Message) error {
 
 	a.buf.Line = msg.Line
 	a.buf.TimeNano = msg.Timestamp.UnixNano()
-	a.buf.Partial = (msg.PLogMetaData != nil)
+	a.buf.Partial = msg.PLogMetaData != nil
 	a.buf.Source = msg.Source
 
 	err := a.enc.Encode(&a.buf)

+ 1 - 1
daemon/logger/awslogs/cloudwatchlogs_test.go

@@ -1139,8 +1139,8 @@ func TestCollectBatchWithDuplicateTimestamps(t *testing.T) {
 	close(d)
 	go stream.collectBatch(d)
 
+	var expectedEvents []*cloudwatchlogs.InputLogEvent
 	times := maximumLogEventsPerPut
-	expectedEvents := []*cloudwatchlogs.InputLogEvent{}
 	timestamp := time.Now()
 	for i := 0; i < times; i++ {
 		line := fmt.Sprintf("%d", i)

+ 1 - 1
daemon/logger/factory.go

@@ -7,7 +7,7 @@ import (
 
 	containertypes "github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/pkg/plugingetter"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/pkg/errors"
 )
 

+ 1 - 2
daemon/logger/gcplogs/gcplogging.go

@@ -1,13 +1,12 @@
 package gcplogs // import "github.com/docker/docker/daemon/logger/gcplogs"
 
 import (
+	"context"
 	"fmt"
 	"sync"
 	"sync/atomic"
 	"time"
 
-	"context"
-
 	"github.com/docker/docker/daemon/logger"
 
 	"cloud.google.com/go/compute/metadata"

+ 1 - 1
daemon/logger/jsonfilelog/jsonfilelog.go

@@ -13,7 +13,7 @@ import (
 	"github.com/docker/docker/daemon/logger"
 	"github.com/docker/docker/daemon/logger/jsonfilelog/jsonlog"
 	"github.com/docker/docker/daemon/logger/loggerutils"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 )

+ 1 - 1
daemon/logger/loggerutils/multireader/multireader_test.go

@@ -205,7 +205,7 @@ func TestMultiReadSeekerCurAfterSet(t *testing.T) {
 }
 
 func TestMultiReadSeekerSmallReads(t *testing.T) {
-	readers := []io.ReadSeeker{}
+	var readers []io.ReadSeeker
 	for i := 0; i < 10; i++ {
 		integer := make([]byte, 4)
 		binary.BigEndian.PutUint32(integer, uint32(i))

+ 1 - 1
daemon/metrics.go

@@ -4,7 +4,7 @@ import (
 	"sync"
 
 	"github.com/docker/docker/pkg/plugingetter"
-	metrics "github.com/docker/go-metrics"
+	"github.com/docker/go-metrics"
 	"github.com/pkg/errors"
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/sirupsen/logrus"

+ 2 - 2
daemon/metrics_unix.go

@@ -10,8 +10,8 @@ import (
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/pkg/plugins"
 	"github.com/docker/docker/plugin"
-	metrics "github.com/docker/go-metrics"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/docker/go-metrics"
+	"github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sys/unix"

+ 1 - 1
daemon/oci_linux.go

@@ -23,7 +23,7 @@ import (
 	"github.com/opencontainers/runc/libcontainer/cgroups"
 	"github.com/opencontainers/runc/libcontainer/devices"
 	"github.com/opencontainers/runc/libcontainer/user"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sys/unix"

+ 1 - 1
daemon/reload_test.go

@@ -89,7 +89,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	actual := []string{}
+	var actual []string
 	serviceConfig := daemon.RegistryService.ServiceConfig()
 	for _, value := range serviceConfig.AllowNondistributableArtifactsCIDRs {
 		actual = append(actual, value.String())

+ 1 - 1
daemon/update_linux.go

@@ -5,7 +5,7 @@ import (
 
 	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/libcontainerd"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 )
 
 func toContainerdResources(resources container.Resources) *libcontainerd.Resources {

+ 1 - 1
distribution/errors_test.go

@@ -48,7 +48,7 @@ func TestContinueOnError_NonMirrorEndpoint(t *testing.T) {
 }
 
 func TestContinueOnError_MirrorEndpoint(t *testing.T) {
-	errs := []error{}
+	var errs []error
 	errs = append(errs, alwaysContinue...)
 	errs = append(errs, continueFromMirrorEndpoint...)
 	for _, err := range errs {

+ 1 - 1
distribution/pull_v2.go

@@ -30,7 +30,7 @@ import (
 	"github.com/docker/docker/pkg/system"
 	refstore "github.com/docker/docker/reference"
 	"github.com/docker/docker/registry"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"

+ 1 - 1
distribution/push_v2.go

@@ -24,7 +24,7 @@ import (
 	"github.com/docker/docker/pkg/progress"
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/registry"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	"github.com/sirupsen/logrus"
 )
 

+ 8 - 8
dockerversion/version_lib.go

@@ -6,12 +6,12 @@ package dockerversion // import "github.com/docker/docker/dockerversion"
 // Default build-time variable for library-import.
 // This file is overridden on build with build-time informations.
 const (
-	GitCommit          string = "library-import"
-	Version            string = "library-import"
-	BuildTime          string = "library-import"
-	IAmStatic          string = "library-import"
-	ContainerdCommitID string = "library-import"
-	RuncCommitID       string = "library-import"
-	InitCommitID       string = "library-import"
-	PlatformName       string = ""
+	GitCommit          = "library-import"
+	Version            = "library-import"
+	BuildTime          = "library-import"
+	IAmStatic          = "library-import"
+	ContainerdCommitID = "library-import"
+	RuncCommitID       = "library-import"
+	InitCommitID       = "library-import"
+	PlatformName       = ""
 )

+ 2 - 2
hack/integration-cli-on-swarm/agent/master/set_test.go

@@ -8,7 +8,7 @@ import (
 )
 
 func generateInput(inputLen int) []string {
-	input := []string{}
+	var input []string
 	for i := 0; i < inputLen; i++ {
 		input = append(input, fmt.Sprintf("s%d", i))
 	}
@@ -21,7 +21,7 @@ func testChunkStrings(t *testing.T, inputLen, numChunks int) {
 	input := generateInput(inputLen)
 	result := chunkStrings(input, numChunks)
 	t.Logf("result has %d chunks", len(result))
-	inputReconstructedFromResult := []string{}
+	var inputReconstructedFromResult []string
 	for i, chunk := range result {
 		t.Logf("chunk %d has %d elements", i, len(chunk))
 		inputReconstructedFromResult = append(inputReconstructedFromResult, chunk...)

+ 1 - 1
image/tarexport/load.go

@@ -23,7 +23,7 @@ import (
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/pkg/symlink"
 	"github.com/docker/docker/pkg/system"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
integration-cli/docker_api_build_test.go

@@ -543,7 +543,7 @@ type buildLine struct {
 }
 
 func getImageIDsFromBuild(c *check.C, output []byte) []string {
-	ids := []string{}
+	var ids []string
 	for _, line := range bytes.Split(output, []byte("\n")) {
 		if len(line) == 0 {
 			continue

+ 2 - 2
integration-cli/docker_api_network_test.go

@@ -289,7 +289,7 @@ func isNetworkAvailable(c *check.C, name string) bool {
 	defer resp.Body.Close()
 	c.Assert(resp.StatusCode, checker.Equals, http.StatusOK)
 
-	nJSON := []types.NetworkResource{}
+	var nJSON []types.NetworkResource
 	err = json.NewDecoder(body).Decode(&nJSON)
 	c.Assert(err, checker.IsNil)
 
@@ -315,7 +315,7 @@ func getNetworkIDByName(c *check.C, name string) string {
 	c.Assert(resp.StatusCode, checker.Equals, http.StatusOK)
 	c.Assert(err, checker.IsNil)
 
-	nJSON := []types.NetworkResource{}
+	var nJSON []types.NetworkResource
 	err = json.NewDecoder(body).Decode(&nJSON)
 	c.Assert(err, checker.IsNil)
 	var res string

+ 3 - 3
integration-cli/docker_cli_build_test.go

@@ -27,7 +27,7 @@ import (
 	"github.com/docker/docker/pkg/archive"
 	"github.com/go-check/check"
 	"github.com/gotestyourself/gotestyourself/icmd"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 )
 
 func (s *DockerSuite) TestBuildJSONEmptyRun(c *check.C) {
@@ -195,7 +195,7 @@ func (s *DockerSuite) TestBuildEnvironmentReplacementEnv(c *check.C) {
   RUN [ "$foo5" = 'abc\def' ]
   `))
 
-	envResult := []string{}
+	var envResult []string
 	inspectFieldAndUnmarshall(c, name, "Config.Env", &envResult)
 	found := false
 	envCount := 0
@@ -4979,7 +4979,7 @@ func (s *DockerSuite) TestBuildLabelMultiple(c *check.C) {
 		"foo": "bar",
 		"123": "456",
 	}
-	labelArgs := []string{}
+	var labelArgs []string
 	for k, v := range testLabels {
 		labelArgs = append(labelArgs, "--label", k+"="+v)
 	}

+ 1 - 1
integration-cli/docker_cli_build_unix_test.go

@@ -19,7 +19,7 @@ import (
 	"github.com/docker/docker/integration-cli/cli"
 	"github.com/docker/docker/integration-cli/cli/build"
 	"github.com/docker/docker/internal/test/fakecontext"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/go-check/check"
 	"github.com/gotestyourself/gotestyourself/icmd"
 )

+ 8 - 8
integration-cli/docker_cli_create_test.go

@@ -26,13 +26,13 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
 
 	out, _ = dockerCmd(c, "inspect", cleanedContainerID)
 
-	containers := []struct {
+	var containers []struct {
 		ID      string
 		Created time.Time
 		Path    string
 		Args    []string
 		Image   string
-	}{}
+	}
 
 	err := json.Unmarshal([]byte(out), &containers)
 	c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
@@ -87,11 +87,11 @@ func (s *DockerSuite) TestCreateHostConfig(c *check.C) {
 
 	out, _ = dockerCmd(c, "inspect", cleanedContainerID)
 
-	containers := []struct {
+	var containers []struct {
 		HostConfig *struct {
 			PublishAllPorts bool
 		}
-	}{}
+	}
 
 	err := json.Unmarshal([]byte(out), &containers)
 	c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
@@ -109,11 +109,11 @@ func (s *DockerSuite) TestCreateWithPortRange(c *check.C) {
 
 	out, _ = dockerCmd(c, "inspect", cleanedContainerID)
 
-	containers := []struct {
+	var containers []struct {
 		HostConfig *struct {
 			PortBindings map[nat.Port][]nat.PortBinding
 		}
-	}{}
+	}
 	err := json.Unmarshal([]byte(out), &containers)
 	c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))
 	c.Assert(containers, checker.HasLen, 1)
@@ -138,11 +138,11 @@ func (s *DockerSuite) TestCreateWithLargePortRange(c *check.C) {
 
 	out, _ = dockerCmd(c, "inspect", cleanedContainerID)
 
-	containers := []struct {
+	var containers []struct {
 		HostConfig *struct {
 			PortBindings map[nat.Port][]nat.PortBinding
 		}
-	}{}
+	}
 
 	err := json.Unmarshal([]byte(out), &containers)
 	c.Assert(err, check.IsNil, check.Commentf("Error inspecting the container: %s", err))

+ 5 - 6
integration-cli/docker_cli_daemon_test.go

@@ -6,6 +6,8 @@ import (
 	"bufio"
 	"bytes"
 	"context"
+	"crypto/tls"
+	"crypto/x509"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -21,9 +23,6 @@ import (
 	"sync"
 	"time"
 
-	"crypto/tls"
-	"crypto/x509"
-
 	"github.com/cloudflare/cfssl/helpers"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api/types"
@@ -36,7 +35,7 @@ import (
 	testdaemon "github.com/docker/docker/internal/test/daemon"
 	"github.com/docker/docker/opts"
 	"github.com/docker/docker/pkg/mount"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 	"github.com/docker/libnetwork/iptables"
 	"github.com/docker/libtrust"
 	"github.com/go-check/check"
@@ -1828,8 +1827,8 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
 func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) {
 	s.d.StartWithBusybox(c)
 
-	parent1Args := []string{}
-	parent2Args := []string{}
+	var parent1Args []string
+	var parent2Args []string
 	wg := sync.WaitGroup{}
 	maxChildren := 10
 	chErr := make(chan error, maxChildren)

+ 1 - 1
integration-cli/docker_cli_exec_test.go

@@ -262,7 +262,7 @@ func (s *DockerSuite) TestExecCgroup(c *check.C) {
 
 	var wg sync.WaitGroup
 	var mu sync.Mutex
-	execCgroups := []sort.StringSlice{}
+	var execCgroups []sort.StringSlice
 	errChan := make(chan error)
 	// exec a few times concurrently to get consistent failure
 	for i := 0; i < 5; i++ {

+ 6 - 6
integration-cli/docker_cli_network_unix_test.go

@@ -273,7 +273,7 @@ func assertNwList(c *check.C, out string, expectNws []string) {
 
 func getNwResource(c *check.C, name string) *types.NetworkResource {
 	out, _ := dockerCmd(c, "network", "inspect", name)
-	nr := []types.NetworkResource{}
+	var nr []types.NetworkResource
 	err := json.Unmarshal([]byte(out), &nr)
 	c.Assert(err, check.IsNil)
 	return &nr[0]
@@ -426,7 +426,7 @@ func (s *DockerSuite) TestDockerNetworkDeleteMultiple(c *check.C) {
 
 func (s *DockerSuite) TestDockerNetworkInspect(c *check.C) {
 	out, _ := dockerCmd(c, "network", "inspect", "host")
-	networkResources := []types.NetworkResource{}
+	var networkResources []types.NetworkResource
 	err := json.Unmarshal([]byte(out), &networkResources)
 	c.Assert(err, check.IsNil)
 	c.Assert(networkResources, checker.HasLen, 1)
@@ -450,7 +450,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) {
 	result := dockerCmdWithResult("network", "inspect", "host", "none")
 	result.Assert(c, icmd.Success)
 
-	networkResources := []types.NetworkResource{}
+	var networkResources []types.NetworkResource
 	err := json.Unmarshal([]byte(result.Stdout()), &networkResources)
 	c.Assert(err, check.IsNil)
 	c.Assert(networkResources, checker.HasLen, 2)
@@ -466,7 +466,7 @@ func (s *DockerSuite) TestDockerInspectMultipleNetworksIncludingNonexistent(c *c
 		Out:      "host",
 	})
 
-	networkResources := []types.NetworkResource{}
+	var networkResources []types.NetworkResource
 	err := json.Unmarshal([]byte(result.Stdout()), &networkResources)
 	c.Assert(err, check.IsNil)
 	c.Assert(networkResources, checker.HasLen, 1)
@@ -512,7 +512,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *check.C) {
 	}()
 
 	out, _ = dockerCmd(c, "network", "inspect", "brNetForInspect")
-	networkResources := []types.NetworkResource{}
+	var networkResources []types.NetworkResource
 	err := json.Unmarshal([]byte(out), &networkResources)
 	c.Assert(err, check.IsNil)
 	c.Assert(networkResources, checker.HasLen, 1)
@@ -526,7 +526,7 @@ func (s *DockerSuite) TestDockerInspectNetworkWithContainerName(c *check.C) {
 
 	// check whether network inspect works properly
 	out, _ = dockerCmd(c, "network", "inspect", "brNetForInspect")
-	newNetRes := []types.NetworkResource{}
+	var newNetRes []types.NetworkResource
 	err = json.Unmarshal([]byte(out), &newNetRes)
 	c.Assert(err, check.IsNil)
 	c.Assert(newNetRes, checker.HasLen, 1)

+ 2 - 2
integration-cli/docker_cli_ps_test.go

@@ -172,7 +172,7 @@ func (s *DockerSuite) TestPsListContainersSize(c *check.C) {
 	idIndex := strings.Index(lines[0], "CONTAINER ID")
 	foundID := lines[1][idIndex : idIndex+12]
 	c.Assert(foundID, checker.Equals, id[:12], check.Commentf("Expected id %s, got %s", id[:12], foundID))
-	expectedSize := fmt.Sprintf("%dB", (2 + baseBytes))
+	expectedSize := fmt.Sprintf("%dB", 2+baseBytes)
 	foundSize := lines[1][sizeIndex:]
 	c.Assert(foundSize, checker.Contains, expectedSize, check.Commentf("Expected size %q, got %q", expectedSize, foundSize))
 }
@@ -377,7 +377,7 @@ func (s *DockerSuite) TestPsListContainersFilterAncestorImage(c *check.C) {
 }
 
 func checkPsAncestorFilterOutput(c *check.C, out string, filterName string, expectedIDs []string) {
-	actualIDs := []string{}
+	var actualIDs []string
 	if out != "" {
 		actualIDs = strings.Split(out[:len(out)-1], "\n")
 	}

+ 3 - 3
integration-cli/docker_cli_pull_local_test.go

@@ -27,7 +27,7 @@ import (
 func testPullImageWithAliases(c *check.C) {
 	repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
 
-	repos := []string{}
+	var repos []string
 	for _, tag := range []string{"recent", "fresh"} {
 		repos = append(repos, fmt.Sprintf("%v:%v", repoName, tag))
 	}
@@ -63,7 +63,7 @@ func (s *DockerSchema1RegistrySuite) TestPullImageWithAliases(c *check.C) {
 func testConcurrentPullWholeRepo(c *check.C) {
 	repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
 
-	repos := []string{}
+	var repos []string
 	for _, tag := range []string{"recent", "fresh", "todays"} {
 		repo := fmt.Sprintf("%v:%v", repoName, tag)
 		buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(`
@@ -151,7 +151,7 @@ func (s *DockerSchema1RegistrySuite) testConcurrentFailingPull(c *check.C) {
 func testConcurrentPullMultipleTags(c *check.C) {
 	repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
 
-	repos := []string{}
+	var repos []string
 	for _, tag := range []string{"recent", "fresh", "todays"} {
 		repo := fmt.Sprintf("%v:%v", repoName, tag)
 		buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(`

+ 1 - 1
integration-cli/docker_cli_push_test.go

@@ -155,7 +155,7 @@ func (s *DockerSchema1RegistrySuite) TestPushEmptyLayer(c *check.C) {
 func testConcurrentPush(c *check.C) {
 	repoName := fmt.Sprintf("%v/dockercli/busybox", privateRegistryURL)
 
-	repos := []string{}
+	var repos []string
 	for _, tag := range []string{"push1", "push2", "push3"} {
 		repo := fmt.Sprintf("%v:%v", repoName, tag)
 		buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(`

+ 3 - 3
integration-cli/docker_cli_save_load_test.go

@@ -19,7 +19,7 @@ import (
 	"github.com/docker/docker/integration-cli/cli/build"
 	"github.com/go-check/check"
 	"github.com/gotestyourself/gotestyourself/icmd"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 )
 
 // save a repo using gz compression and try to load it using stdout
@@ -100,10 +100,10 @@ func (s *DockerSuite) TestSaveCheckTimes(c *check.C) {
 	testRequires(c, DaemonIsLinux)
 	repoName := "busybox:latest"
 	out, _ := dockerCmd(c, "inspect", repoName)
-	data := []struct {
+	var data []struct {
 		ID      string
 		Created time.Time
-	}{}
+	}
 	err := json.Unmarshal([]byte(out), &data)
 	c.Assert(err, checker.IsNil, check.Commentf("failed to marshal from %q: err %v", repoName, err))
 	c.Assert(len(data), checker.Not(checker.Equals), 0, check.Commentf("failed to marshal the data from %q", repoName))

+ 1 - 1
integration-cli/docker_cli_sni_test.go

@@ -16,7 +16,7 @@ import (
 func (s *DockerSuite) TestClientSetsTLSServerName(c *check.C) {
 	c.Skip("Flakey test")
 	// there may be more than one hit to the server for each registry request
-	serverNameReceived := []string{}
+	var serverNameReceived []string
 	var serverName string
 
 	virtualHostServer := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

+ 0 - 1
integration-cli/environment/environment.go

@@ -2,7 +2,6 @@ package environment // import "github.com/docker/docker/integration-cli/environm
 
 import (
 	"os"
-
 	"os/exec"
 
 	"github.com/docker/docker/internal/test/environment"

+ 2 - 2
integration-cli/utils_test.go

@@ -119,7 +119,7 @@ type elementListOptions struct {
 }
 
 func existingElements(c *check.C, opts elementListOptions) []string {
-	args := []string{}
+	var args []string
 	switch opts.element {
 	case "container":
 		args = append(args, "ps", "-a")
@@ -136,7 +136,7 @@ func existingElements(c *check.C, opts elementListOptions) []string {
 		args = append(args, "--format", opts.format)
 	}
 	out, _ := dockerCmd(c, args...)
-	lines := []string{}
+	var lines []string
 	for _, l := range strings.Split(out, "\n") {
 		if l != "" {
 			lines = append(lines, l)

+ 1 - 1
integration/build/build_test.go

@@ -443,7 +443,7 @@ type buildLine struct {
 }
 
 func getImageIDsFromBuild(output []byte) ([]string, error) {
-	ids := []string{}
+	var ids []string
 	for _, line := range bytes.Split(output, []byte("\n")) {
 		if len(line) == 0 {
 			continue

+ 1 - 1
integration/config/config_test.go

@@ -46,7 +46,7 @@ func TestConfigList(t *testing.T) {
 	config1ID := createConfig(ctx, t, client, testName1, []byte("TESTINGDATA1"), map[string]string{"type": "production"})
 
 	names := func(entries []swarmtypes.Config) []string {
-		values := []string{}
+		var values []string
 		for _, entry := range entries {
 			values = append(values, entry.Spec.Name)
 		}

+ 2 - 2
integration/container/pause_test.go

@@ -51,7 +51,7 @@ func TestPause(t *testing.T) {
 }
 
 func TestPauseFailsOnWindowsServerContainers(t *testing.T) {
-	skip.If(t, (testEnv.DaemonInfo.OSType != "windows" || testEnv.DaemonInfo.Isolation != "process"))
+	skip.If(t, testEnv.DaemonInfo.OSType != "windows" || testEnv.DaemonInfo.Isolation != "process")
 
 	defer setupTest(t)()
 	client := request.NewAPIClient(t)
@@ -85,7 +85,7 @@ func TestPauseStopPausedContainer(t *testing.T) {
 }
 
 func getEventActions(t *testing.T, messages <-chan events.Message, errs <-chan error) []string {
-	actions := []string{}
+	var actions []string
 	for {
 		select {
 		case err := <-errs:

+ 1 - 1
integration/container/ps_test.go

@@ -22,7 +22,7 @@ func TestPsFilter(t *testing.T) {
 	next := container.Create(t, ctx, client)
 
 	containerIDs := func(containers []types.Container) []string {
-		entries := []string{}
+		var entries []string
 		for _, container := range containers {
 			entries = append(entries, container.ID)
 		}

+ 2 - 2
integration/network/service_test.go

@@ -173,8 +173,8 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) {
 	out1, err := cli.NetworkInspect(context.Background(), name, types.NetworkInspectOptions{})
 	assert.NilError(t, err)
 
-	assert.Check(t, (out1.IPAM.Config[0].Subnet != networkip))
-	assert.Check(t, (out1.IPAM.Config[0].Subnet != networkip2))
+	assert.Check(t, out1.IPAM.Config[0].Subnet != networkip)
+	assert.Check(t, out1.IPAM.Config[0].Subnet != networkip2)
 	delInterface(t, defaultNetworkBridge)
 }
 

+ 1 - 1
integration/secret/secret_test.go

@@ -63,7 +63,7 @@ func TestSecretList(t *testing.T) {
 	secret1ID := createSecret(ctx, t, client, testName1, []byte("TESTINGDATA1"), map[string]string{"type": "production"})
 
 	names := func(entries []swarmtypes.Secret) []string {
-		values := []string{}
+		var values []string
 		for _, entry := range entries {
 			values = append(values, entry.Spec.Name)
 		}

+ 6 - 6
internal/test/environment/protect.go

@@ -77,7 +77,7 @@ func getExistingContainers(t assert.TestingT, testEnv *Execution) []string {
 	})
 	assert.NilError(t, err, "failed to list containers")
 
-	containers := []string{}
+	var containers []string
 	for _, container := range containerList {
 		containers = append(containers, container.ID)
 	}
@@ -121,7 +121,7 @@ func getExistingImages(t assert.TestingT, testEnv *Execution) []string {
 	})
 	assert.NilError(t, err, "failed to list images")
 
-	images := []string{}
+	var images []string
 	for _, image := range imageList {
 		images = append(images, tagsFromImageSummary(image)...)
 	}
@@ -129,7 +129,7 @@ func getExistingImages(t assert.TestingT, testEnv *Execution) []string {
 }
 
 func tagsFromImageSummary(image types.ImageSummary) []string {
-	result := []string{}
+	var result []string
 	for _, tag := range image.RepoTags {
 		if tag != "<none>:<none>" {
 			result = append(result, tag)
@@ -172,7 +172,7 @@ func getExistingNetworks(t assert.TestingT, testEnv *Execution) []string {
 	networkList, err := client.NetworkList(context.Background(), types.NetworkListOptions{})
 	assert.NilError(t, err, "failed to list networks")
 
-	networks := []string{}
+	var networks []string
 	for _, network := range networkList {
 		networks = append(networks, network.ID)
 	}
@@ -211,7 +211,7 @@ func getExistingPlugins(t assert.TestingT, testEnv *Execution) []string {
 	}
 	assert.NilError(t, err, "failed to list plugins")
 
-	plugins := []string{}
+	var plugins []string
 	for _, plugin := range pluginList {
 		plugins = append(plugins, plugin.Name)
 	}
@@ -246,7 +246,7 @@ func getExistingVolumes(t assert.TestingT, testEnv *Execution) []string {
 	volumeList, err := client.VolumeList(context.Background(), filters.Args{})
 	assert.NilError(t, err, "failed to list volumes")
 
-	volumes := []string{}
+	var volumes []string
 	for _, volume := range volumeList.Volumes {
 		volumes = append(volumes, volume.Name)
 	}

+ 1 - 1
libcontainerd/client_daemon_linux.go

@@ -10,7 +10,7 @@ import (
 	"github.com/containerd/containerd"
 	"github.com/containerd/containerd/cio"
 	"github.com/docker/docker/pkg/idtools"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
libcontainerd/types_linux.go

@@ -4,7 +4,7 @@ import (
 	"time"
 
 	"github.com/containerd/cgroups"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 )
 
 // Summary is not used on linux

+ 1 - 2
migrate/v1/migratev1.go

@@ -1,6 +1,7 @@
 package v1 // import "github.com/docker/docker/migrate/v1"
 
 import (
+	"encoding/json"
 	"errors"
 	"fmt"
 	"io/ioutil"
@@ -11,8 +12,6 @@ import (
 	"sync"
 	"time"
 
-	"encoding/json"
-
 	"github.com/docker/distribution/reference"
 	"github.com/docker/docker/distribution/metadata"
 	"github.com/docker/docker/image"

+ 1 - 1
oci/devices_linux.go

@@ -8,7 +8,7 @@ import (
 
 	"github.com/opencontainers/runc/libcontainer/configs"
 	"github.com/opencontainers/runc/libcontainer/devices"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 )
 
 // Device transforms a libcontainer configs.Device to a specs.LinuxDevice object.

+ 1 - 1
oci/namespaces.go

@@ -1,6 +1,6 @@
 package oci // import "github.com/docker/docker/oci"
 
-import specs "github.com/opencontainers/runtime-spec/specs-go"
+import "github.com/opencontainers/runtime-spec/specs-go"
 
 // RemoveNamespace removes the `nsType` namespace from OCI spec `s`
 func RemoveNamespace(s *specs.Spec, nsType specs.LinuxNamespaceType) {

+ 1 - 1
opts/address_pools.go

@@ -65,7 +65,7 @@ func (p *PoolsOpt) Type() string {
 
 // String returns a string repr of this option
 func (p *PoolsOpt) String() string {
-	pools := []string{}
+	var pools []string
 	for _, pool := range p.values {
 		repr := fmt.Sprintf("%s %d", pool.Base, pool.Size)
 		pools = append(pools, repr)

+ 5 - 5
opts/opts.go

@@ -7,7 +7,7 @@ import (
 	"regexp"
 	"strings"
 
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 )
 
 var (
@@ -52,7 +52,7 @@ func (opts *ListOpts) Set(value string) error {
 		}
 		value = v
 	}
-	(*opts.values) = append((*opts.values), value)
+	*opts.values = append(*opts.values, value)
 	return nil
 }
 
@@ -60,7 +60,7 @@ func (opts *ListOpts) Set(value string) error {
 func (opts *ListOpts) Delete(key string) {
 	for i, k := range *opts.values {
 		if k == key {
-			(*opts.values) = append((*opts.values)[:i], (*opts.values)[i+1:]...)
+			*opts.values = append((*opts.values)[:i], (*opts.values)[i+1:]...)
 			return
 		}
 	}
@@ -78,7 +78,7 @@ func (opts *ListOpts) GetMap() map[string]struct{} {
 
 // GetAll returns the values of slice.
 func (opts *ListOpts) GetAll() []string {
-	return (*opts.values)
+	return *opts.values
 }
 
 // GetAllOrEmpty returns the values of the slice
@@ -103,7 +103,7 @@ func (opts *ListOpts) Get(key string) bool {
 
 // Len returns the amount of element in the slice.
 func (opts *ListOpts) Len() int {
-	return len((*opts.values))
+	return len(*opts.values)
 }
 
 // Type returns a string name for this Option type

+ 1 - 1
pkg/archive/changes_posix_test.go

@@ -112,7 +112,7 @@ func (th tarHeaders) Less(i, j int) bool { return th[i].Name < th[j].Name }
 
 func walkHeaders(r io.Reader) ([]tar.Header, error) {
 	t := tar.NewReader(r)
-	headers := []tar.Header{}
+	var headers []tar.Header
 	for {
 		hdr, err := t.Next()
 		if err != nil {

+ 1 - 1
pkg/archive/time_linux.go

@@ -9,7 +9,7 @@ func timeToTimespec(time time.Time) (ts syscall.Timespec) {
 	if time.IsZero() {
 		// Return UTIME_OMIT special value
 		ts.Sec = 0
-		ts.Nsec = ((1 << 30) - 2)
+		ts.Nsec = (1 << 30) - 2
 		return
 	}
 	return syscall.NsecToTimespec(time.UnixNano())

+ 0 - 1
pkg/broadcaster/unbuffered_test.go

@@ -4,7 +4,6 @@ import (
 	"bytes"
 	"errors"
 	"strings"
-
 	"testing"
 )
 

+ 1 - 1
pkg/devicemapper/devmapper_wrapper.go

@@ -216,7 +216,7 @@ func dmGetNextTargetFct(task *cdmTask, next unsafe.Pointer, start, length *uint6
 }
 
 func dmUdevSetSyncSupportFct(syncWithUdev int) {
-	(C.dm_udev_set_sync_support(C.int(syncWithUdev)))
+	C.dm_udev_set_sync_support(C.int(syncWithUdev))
 }
 
 func dmUdevGetSyncSupportFct() int {

+ 2 - 2
pkg/idtools/idtools.go

@@ -30,8 +30,8 @@ func (e ranges) Swap(i, j int)      { e[i], e[j] = e[j], e[i] }
 func (e ranges) Less(i, j int) bool { return e[i].Start < e[j].Start }
 
 const (
-	subuidFileName string = "/etc/subuid"
-	subgidFileName string = "/etc/subgid"
+	subuidFileName = "/etc/subuid"
+	subgidFileName = "/etc/subgid"
 )
 
 // MkdirAllAndChown creates a directory (include any along the path) and then modifies

+ 2 - 2
pkg/jsonmessage/jsonmessage.go

@@ -8,9 +8,9 @@ import (
 	"strings"
 	"time"
 
-	gotty "github.com/Nvveen/Gotty"
+	"github.com/Nvveen/Gotty"
 	"github.com/docker/docker/pkg/term"
-	units "github.com/docker/go-units"
+	"github.com/docker/go-units"
 )
 
 // RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to

+ 4 - 4
pkg/pubsub/publisher_test.go

@@ -20,7 +20,7 @@ func TestSendToOneSub(t *testing.T) {
 
 func TestSendToMultipleSubs(t *testing.T) {
 	p := NewPublisher(100*time.Millisecond, 10)
-	subs := []chan interface{}{}
+	var subs []chan interface{}
 	subs = append(subs, p.Subscribe(), p.Subscribe(), p.Subscribe())
 
 	p.Publish("hi")
@@ -52,7 +52,7 @@ func TestEvictOneSub(t *testing.T) {
 
 func TestClosePublisher(t *testing.T) {
 	p := NewPublisher(100*time.Millisecond, 10)
-	subs := []chan interface{}{}
+	var subs []chan interface{}
 	subs = append(subs, p.Subscribe(), p.Subscribe(), p.Subscribe())
 	p.Close()
 
@@ -99,7 +99,7 @@ func newTestSubscriber(p *Publisher) *testSubscriber {
 // for testing with -race
 func TestPubSubRace(t *testing.T) {
 	p := NewPublisher(0, 1024)
-	var subs [](*testSubscriber)
+	var subs []*testSubscriber
 	for j := 0; j < 50; j++ {
 		subs = append(subs, newTestSubscriber(p))
 	}
@@ -120,7 +120,7 @@ func BenchmarkPubSub(b *testing.B) {
 	for i := 0; i < b.N; i++ {
 		b.StopTimer()
 		p := NewPublisher(0, 1024)
-		var subs [](*testSubscriber)
+		var subs []*testSubscriber
 		for j := 0; j < 50; j++ {
 			subs = append(subs, newTestSubscriber(p))
 		}

+ 1 - 1
pkg/signal/signal.go

@@ -13,7 +13,7 @@ import (
 
 // CatchAll catches all signals and relays them to the specified channel.
 func CatchAll(sigc chan os.Signal) {
-	handledSigs := []os.Signal{}
+	var handledSigs []os.Signal
 	for _, s := range SignalMap {
 		handledSigs = append(handledSigs, s)
 	}

+ 1 - 1
pkg/term/windows/windows.go

@@ -9,7 +9,7 @@ import (
 	"os"
 	"sync"
 
-	ansiterm "github.com/Azure/go-ansiterm"
+	"github.com/Azure/go-ansiterm"
 	"github.com/sirupsen/logrus"
 )
 

+ 1 - 1
pkg/truncindex/truncindex_test.go

@@ -10,7 +10,7 @@ import (
 
 // Test the behavior of TruncIndex, an index for querying IDs from a non-conflicting prefix.
 func TestTruncIndex(t *testing.T) {
-	ids := []string{}
+	var ids []string
 	index := NewTruncIndex(ids)
 	// Get on an empty index
 	if _, err := index.Get("foobar"); err == nil {

+ 1 - 1
plugin/backend_linux.go

@@ -33,7 +33,7 @@ import (
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/plugin/v2"
 	refstore "github.com/docker/docker/reference"
-	digest "github.com/opencontainers/go-digest"
+	"github.com/opencontainers/go-digest"
 	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"

+ 1 - 1
plugin/defs.go

@@ -5,7 +5,7 @@ import (
 
 	"github.com/docker/docker/pkg/plugins"
 	"github.com/docker/docker/plugin/v2"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 )
 
 // Store manages the plugin inventory in memory and on-disk

+ 1 - 1
plugin/executor/containerd/containerd_test.go

@@ -10,7 +10,7 @@ import (
 
 	"github.com/docker/docker/libcontainerd"
 	"github.com/gotestyourself/gotestyourself/assert"
-	specs "github.com/opencontainers/runtime-spec/specs-go"
+	"github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 )
 

Some files were not shown because too many files changed in this diff