Browse Source

Merge pull request #39668 from thaJeztah/replace_gometalinter

Replace gometalinter with golangci-lint
Yong Tang 5 years ago
parent
commit
ad1b781e44
100 changed files with 171 additions and 167 deletions
  1. 3 3
      Dockerfile
  2. 4 4
      api/server/httputils/httputils.go
  3. 2 2
      api/server/httputils/write_log_stream.go
  4. 7 7
      api/server/router/build/build_routes.go
  5. 1 1
      api/server/router/distribution/distribution_routes.go
  6. 4 4
      api/server/router/image/image_routes.go
  7. 3 3
      api/server/router/plugin/plugin_routes.go
  8. 1 1
      api/server/router/system/system.go
  9. 1 1
      api/types/container/host_config.go
  10. 1 1
      api/types/filters/parse.go
  11. 5 2
      api/types/filters/parse_test.go
  12. 1 1
      api/types/registry/registry.go
  13. 13 13
      builder/builder-next/adapters/containerimage/pull.go
  14. 3 3
      builder/builder-next/exporter/export.go
  15. 5 5
      builder/builder-next/exporter/writer.go
  16. 4 4
      builder/builder-next/worker/worker.go
  17. 1 1
      builder/dockerfile/copy_unix.go
  18. 1 1
      builder/dockerfile/copy_windows.go
  19. 2 3
      builder/dockerfile/imagecontext.go
  20. 1 1
      builder/dockerfile/metrics.go
  21. 1 0
      builder/fscache/fscache.go
  22. 2 2
      builder/remotecontext/git/gitutils.go
  23. 1 0
      builder/remotecontext/remote.go
  24. 1 1
      builder/remotecontext/tarsum.go
  25. 1 0
      client/container_list.go
  26. 1 0
      client/events.go
  27. 2 0
      client/hijack.go
  28. 1 1
      client/image_build_test.go
  29. 1 0
      client/image_list.go
  30. 1 0
      client/network_list.go
  31. 1 0
      client/plugin_list.go
  32. 0 9
      client/request.go
  33. 1 1
      client/service_create.go
  34. 2 2
      client/service_create_test.go
  35. 1 0
      client/volume_list.go
  36. 3 3
      cmd/dockerd/config.go
  37. 1 1
      cmd/dockerd/config_unix.go
  38. 1 1
      cmd/dockerd/metrics.go
  39. 1 1
      cmd/dockerd/service_windows.go
  40. 1 1
      container/container.go
  41. 1 1
      container/state.go
  42. 1 1
      container/view.go
  43. 1 1
      contrib/docker-device-tool/device_tool.go
  44. 3 3
      daemon/checkpoint.go
  45. 1 2
      daemon/cluster/controllers/plugin/controller.go
  46. 1 1
      daemon/cluster/controllers/plugin/controller_test.go
  47. 1 1
      daemon/cluster/executor/container/adapter.go
  48. 0 4
      daemon/cluster/executor/container/container.go
  49. 1 1
      daemon/cluster/executor/container/controller.go
  50. 1 1
      daemon/cluster/nodes.go
  51. 1 1
      daemon/config/config_unix.go
  52. 1 1
      daemon/config/config_unix_test.go
  53. 1 1
      daemon/events/metrics.go
  54. 1 1
      daemon/exec.go
  55. 1 1
      daemon/exec_linux.go
  56. 1 1
      daemon/exec_linux_test.go
  57. 1 1
      daemon/graphdriver/btrfs/btrfs.go
  58. 0 3
      daemon/graphdriver/copy/copy.go
  59. 1 1
      daemon/graphdriver/devmapper/deviceset.go
  60. 1 1
      daemon/graphdriver/devmapper/devmapper_test.go
  61. 1 1
      daemon/graphdriver/devmapper/driver.go
  62. 4 0
      daemon/graphdriver/graphtest/graphbench_unix.go
  63. 1 1
      daemon/graphdriver/graphtest/graphtest_unix.go
  64. 1 1
      daemon/graphdriver/overlay2/overlay.go
  65. 1 1
      daemon/graphdriver/plugin.go
  66. 1 1
      daemon/graphdriver/vfs/driver.go
  67. 1 0
      daemon/graphdriver/vfs/quota_linux.go
  68. 1 1
      daemon/graphdriver/windows/windows.go
  69. 1 1
      daemon/images/image_prune.go
  70. 1 1
      daemon/images/image_pull.go
  71. 1 1
      daemon/images/locals.go
  72. 1 1
      daemon/images/service.go
  73. 1 1
      daemon/info.go
  74. 2 2
      daemon/info_unix_test.go
  75. 1 1
      daemon/list_test.go
  76. 1 1
      daemon/listeners/listeners_windows.go
  77. 2 3
      daemon/logger/copier_test.go
  78. 1 1
      daemon/logger/factory.go
  79. 1 1
      daemon/logger/fluentd/fluentd.go
  80. 1 1
      daemon/logger/journald/journald.go
  81. 1 1
      daemon/logger/jsonfilelog/jsonfilelog.go
  82. 4 4
      daemon/logger/jsonfilelog/jsonfilelog_test.go
  83. 1 1
      daemon/logger/local/local.go
  84. 1 1
      daemon/logger/metrics.go
  85. 1 1
      daemon/metrics.go
  86. 2 2
      daemon/metrics_unix.go
  87. 3 5
      daemon/monitor.go
  88. 0 6
      daemon/network.go
  89. 13 0
      daemon/network_windows.go
  90. 1 1
      daemon/nvidia_linux.go
  91. 1 1
      daemon/oci_linux.go
  92. 1 1
      daemon/oci_utils.go
  93. 1 1
      daemon/oci_windows.go
  94. 1 1
      daemon/oci_windows_test.go
  95. 3 3
      daemon/seccomp_linux.go
  96. 1 1
      daemon/selinux_linux.go
  97. 1 1
      daemon/top_windows.go
  98. 1 1
      daemon/update_linux.go
  99. 1 1
      distribution/config.go
  100. 1 1
      distribution/errors.go

+ 3 - 3
Dockerfile

@@ -176,8 +176,8 @@ COPY hack/dockerfile/install/install.sh ./install.sh
 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
 
 
-FROM base AS gometalinter
-ENV INSTALL_BINARY_NAME=gometalinter
+FROM base AS golangci_lint
+ENV INSTALL_BINARY_NAME=golangci_lint
 COPY hack/dockerfile/install/install.sh ./install.sh
 COPY hack/dockerfile/install/install.sh ./install.sh
 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
 RUN PREFIX=/build ./install.sh $INSTALL_BINARY_NAME
@@ -265,7 +265,7 @@ RUN pip3 install yamllint==1.16.0
 
 
 COPY --from=swagger /build/swagger* /usr/local/bin/
 COPY --from=swagger /build/swagger* /usr/local/bin/
 COPY --from=frozen-images /build/ /docker-frozen-images
 COPY --from=frozen-images /build/ /docker-frozen-images
-COPY --from=gometalinter /build/ /usr/local/bin/
+COPY --from=golangci_lint /build/ /usr/local/bin/
 COPY --from=gotestsum /build/ /usr/local/bin/
 COPY --from=gotestsum /build/ /usr/local/bin/
 COPY --from=tomlv /build/ /usr/local/bin/
 COPY --from=tomlv /build/ /usr/local/bin/
 COPY --from=vndr /build/ /usr/local/bin/
 COPY --from=vndr /build/ /usr/local/bin/

+ 4 - 4
api/server/httputils/httputils.go

@@ -31,7 +31,7 @@ func HijackConnection(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
 		return nil, nil, err
 		return nil, nil, err
 	}
 	}
 	// Flush the options to make sure the client sets the raw mode
 	// Flush the options to make sure the client sets the raw mode
-	conn.Write([]byte{})
+	_, _ = conn.Write([]byte{})
 	return conn, conn, nil
 	return conn, conn, nil
 }
 }
 
 
@@ -41,9 +41,9 @@ func CloseStreams(streams ...interface{}) {
 		if tcpc, ok := stream.(interface {
 		if tcpc, ok := stream.(interface {
 			CloseWrite() error
 			CloseWrite() error
 		}); ok {
 		}); ok {
-			tcpc.CloseWrite()
+			_ = tcpc.CloseWrite()
 		} else if closer, ok := stream.(io.Closer); ok {
 		} else if closer, ok := stream.(io.Closer); ok {
-			closer.Close()
+			_ = closer.Close()
 		}
 		}
 	}
 	}
 }
 }
@@ -102,7 +102,7 @@ func MakeErrorHandler(err error) http.HandlerFunc {
 			response := &types.ErrorResponse{
 			response := &types.ErrorResponse{
 				Message: err.Error(),
 				Message: err.Error(),
 			}
 			}
-			WriteJSON(w, statusCode, response)
+			_ = WriteJSON(w, statusCode, response)
 		} else {
 		} else {
 			http.Error(w, status.Convert(err).Message(), statusCode)
 			http.Error(w, status.Convert(err).Message(), statusCode)
 		}
 		}

+ 2 - 2
api/server/httputils/write_log_stream.go

@@ -51,10 +51,10 @@ func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMess
 			logLine = append([]byte(msg.Timestamp.Format(jsonmessage.RFC3339NanoFixed)+" "), logLine...)
 			logLine = append([]byte(msg.Timestamp.Format(jsonmessage.RFC3339NanoFixed)+" "), logLine...)
 		}
 		}
 		if msg.Source == "stdout" && config.ShowStdout {
 		if msg.Source == "stdout" && config.ShowStdout {
-			outStream.Write(logLine)
+			_, _ = outStream.Write(logLine)
 		}
 		}
 		if msg.Source == "stderr" && config.ShowStderr {
 		if msg.Source == "stderr" && config.ShowStderr {
-			errStream.Write(logLine)
+			_, _ = errStream.Write(logLine)
 		}
 		}
 	}
 	}
 }
 }

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

@@ -176,7 +176,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
 	if err := httputils.ParseForm(r); err != nil {
 	if err := httputils.ParseForm(r); err != nil {
 		return err
 		return err
 	}
 	}
-	filters, err := filters.FromJSON(r.Form.Get("filters"))
+	fltrs, err := filters.FromJSON(r.Form.Get("filters"))
 	if err != nil {
 	if err != nil {
 		return errors.Wrap(err, "could not parse filters")
 		return errors.Wrap(err, "could not parse filters")
 	}
 	}
@@ -191,7 +191,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
 
 
 	opts := types.BuildCachePruneOptions{
 	opts := types.BuildCachePruneOptions{
 		All:         httputils.BoolValue(r, "all"),
 		All:         httputils.BoolValue(r, "all"),
-		Filters:     filters,
+		Filters:     fltrs,
 		KeepStorage: int64(ks),
 		KeepStorage: int64(ks),
 	}
 	}
 
 
@@ -234,12 +234,12 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
 	}
 	}
 
 
 	output := ioutils.NewWriteFlusher(ww)
 	output := ioutils.NewWriteFlusher(ww)
-	defer output.Close()
+	defer func() { _ = output.Close() }()
 
 
 	errf := func(err error) error {
 	errf := func(err error) error {
 
 
 		if httputils.BoolValue(r, "q") && notVerboseBuffer.Len() > 0 {
 		if httputils.BoolValue(r, "q") && notVerboseBuffer.Len() > 0 {
-			output.Write(notVerboseBuffer.Bytes())
+			_, _ = output.Write(notVerboseBuffer.Bytes())
 		}
 		}
 
 
 		// Do not write the error in the http output if it's still empty.
 		// Do not write the error in the http output if it's still empty.
@@ -290,7 +290,7 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
 	// Everything worked so if -q was provided the output from the daemon
 	// Everything worked so if -q was provided the output from the daemon
 	// should be just the image ID and we'll print that to stdout.
 	// should be just the image ID and we'll print that to stdout.
 	if buildOptions.SuppressOutput {
 	if buildOptions.SuppressOutput {
-		fmt.Fprintln(streamformatter.NewStdoutWriter(output), imgID)
+		_, _ = fmt.Fprintln(streamformatter.NewStdoutWriter(output), imgID)
 	}
 	}
 	return nil
 	return nil
 }
 }
@@ -306,7 +306,7 @@ func getAuthConfigs(header http.Header) map[string]types.AuthConfig {
 	authConfigsJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authConfigsEncoded))
 	authConfigsJSON := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authConfigsEncoded))
 	// Pulling an image does not error when no auth is provided so to remain
 	// Pulling an image does not error when no auth is provided so to remain
 	// consistent with the existing api decode errors are ignored
 	// consistent with the existing api decode errors are ignored
-	json.NewDecoder(authConfigsJSON).Decode(&authConfigs)
+	_ = json.NewDecoder(authConfigsJSON).Decode(&authConfigs)
 	return authConfigs
 	return authConfigs
 }
 }
 
 
@@ -428,7 +428,7 @@ func (w *wcf) notify() {
 	w.mu.Lock()
 	w.mu.Lock()
 	if !w.ready {
 	if !w.ready {
 		if w.buf.Len() > 0 {
 		if w.buf.Len() > 0 {
-			io.Copy(w.Writer, w.buf)
+			_, _ = io.Copy(w.Writer, w.buf)
 		}
 		}
 		if w.flushed {
 		if w.flushed {
 			w.flusher.Flush()
 			w.flusher.Flush()

+ 1 - 1
api/server/router/distribution/distribution_routes.go

@@ -15,7 +15,7 @@ import (
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
 	registrytypes "github.com/docker/docker/api/types/registry"
 	registrytypes "github.com/docker/docker/api/types/registry"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
-	"github.com/opencontainers/image-spec/specs-go/v1"
+	v1 "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 )
 )
 
 

+ 4 - 4
api/server/router/image/image_routes.go

@@ -91,7 +91,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
 		if !output.Flushed() {
 		if !output.Flushed() {
 			return err
 			return err
 		}
 		}
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 
 
 	return nil
 	return nil
@@ -136,7 +136,7 @@ func (s *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter,
 		if !output.Flushed() {
 		if !output.Flushed() {
 			return err
 			return err
 		}
 		}
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 	return nil
 	return nil
 }
 }
@@ -161,7 +161,7 @@ func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r
 		if !output.Flushed() {
 		if !output.Flushed() {
 			return err
 			return err
 		}
 		}
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 	return nil
 	return nil
 }
 }
@@ -177,7 +177,7 @@ func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter,
 	output := ioutils.NewWriteFlusher(w)
 	output := ioutils.NewWriteFlusher(w)
 	defer output.Close()
 	defer output.Close()
 	if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
 	if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 	return nil
 	return nil
 }
 }

+ 3 - 3
api/server/router/plugin/plugin_routes.go

@@ -123,7 +123,7 @@ func (pr *pluginRouter) upgradePlugin(ctx context.Context, w http.ResponseWriter
 		if !output.Flushed() {
 		if !output.Flushed() {
 			return err
 			return err
 		}
 		}
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 
 
 	return nil
 	return nil
@@ -162,7 +162,7 @@ func (pr *pluginRouter) pullPlugin(ctx context.Context, w http.ResponseWriter, r
 		if !output.Flushed() {
 		if !output.Flushed() {
 			return err
 			return err
 		}
 		}
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 
 
 	return nil
 	return nil
@@ -270,7 +270,7 @@ func (pr *pluginRouter) pushPlugin(ctx context.Context, w http.ResponseWriter, r
 		if !output.Flushed() {
 		if !output.Flushed() {
 			return err
 			return err
 		}
 		}
-		output.Write(streamformatter.FormatError(err))
+		_, _ = output.Write(streamformatter.FormatError(err))
 	}
 	}
 	return nil
 	return nil
 }
 }

+ 1 - 1
api/server/router/system/system.go

@@ -2,7 +2,7 @@ package system // import "github.com/docker/docker/api/server/router/system"
 
 
 import (
 import (
 	"github.com/docker/docker/api/server/router"
 	"github.com/docker/docker/api/server/router"
-	"github.com/docker/docker/builder/builder-next"
+	buildkit "github.com/docker/docker/builder/builder-next"
 	"github.com/docker/docker/builder/fscache"
 	"github.com/docker/docker/builder/fscache"
 )
 )
 
 

+ 1 - 1
api/types/container/host_config.go

@@ -7,7 +7,7 @@ import (
 	"github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/api/types/mount"
 	"github.com/docker/docker/api/types/strslice"
 	"github.com/docker/docker/api/types/strslice"
 	"github.com/docker/go-connections/nat"
 	"github.com/docker/go-connections/nat"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 )
 )
 
 
 // CgroupnsMode represents the cgroup namespace mode of the container
 // CgroupnsMode represents the cgroup namespace mode of the container

+ 1 - 1
api/types/filters/parse.go

@@ -57,7 +57,7 @@ func ToJSON(a Args) (string, error) {
 // then the encoded format will use an older legacy format where the values are a
 // then the encoded format will use an older legacy format where the values are a
 // list of strings, instead of a set.
 // list of strings, instead of a set.
 //
 //
-// Deprecated: Use ToJSON
+// Deprecated: do not use in any new code; use ToJSON instead
 func ToParamWithVersion(version string, a Args) (string, error) {
 func ToParamWithVersion(version string, a Args) (string, error) {
 	if a.Len() == 0 {
 	if a.Len() == 0 {
 		return "", nil
 		return "", nil

+ 5 - 2
api/types/filters/parse_test.go

@@ -337,14 +337,17 @@ func TestWalkValues(t *testing.T) {
 	f.Add("status", "running")
 	f.Add("status", "running")
 	f.Add("status", "paused")
 	f.Add("status", "paused")
 
 
-	f.WalkValues("status", func(value string) error {
+	err := f.WalkValues("status", func(value string) error {
 		if value != "running" && value != "paused" {
 		if value != "running" && value != "paused" {
 			t.Fatalf("Unexpected value %s", value)
 			t.Fatalf("Unexpected value %s", value)
 		}
 		}
 		return nil
 		return nil
 	})
 	})
+	if err != nil {
+		t.Fatalf("Expected no error, got %v", err)
+	}
 
 
-	err := f.WalkValues("status", func(value string) error {
+	err = f.WalkValues("status", func(value string) error {
 		return errors.New("return")
 		return errors.New("return")
 	})
 	})
 	if err == nil {
 	if err == nil {

+ 1 - 1
api/types/registry/registry.go

@@ -4,7 +4,7 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"net"
 	"net"
 
 
-	"github.com/opencontainers/image-spec/specs-go/v1"
+	v1 "github.com/opencontainers/image-spec/specs-go/v1"
 )
 )
 
 
 // ServiceConfig stores daemon registry services configuration.
 // ServiceConfig stores daemon registry services configuration.

+ 13 - 13
builder/builder-next/adapters/containerimage/pull.go

@@ -37,7 +37,7 @@ import (
 	"github.com/moby/buildkit/util/progress"
 	"github.com/moby/buildkit/util/progress"
 	"github.com/moby/buildkit/util/resolver"
 	"github.com/moby/buildkit/util/resolver"
 	"github.com/moby/buildkit/util/tracing"
 	"github.com/moby/buildkit/util/tracing"
-	"github.com/opencontainers/go-digest"
+	digest "github.com/opencontainers/go-digest"
 	"github.com/opencontainers/image-spec/identity"
 	"github.com/opencontainers/image-spec/identity"
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
@@ -275,7 +275,7 @@ func (p *puller) resolve(ctx context.Context) error {
 		ref, err := distreference.ParseNormalizedNamed(p.src.Reference.String())
 		ref, err := distreference.ParseNormalizedNamed(p.src.Reference.String())
 		if err != nil {
 		if err != nil {
 			p.resolveErr = err
 			p.resolveErr = err
-			resolveProgressDone(err)
+			_ = resolveProgressDone(err)
 			return
 			return
 		}
 		}
 
 
@@ -283,7 +283,7 @@ func (p *puller) resolve(ctx context.Context) error {
 			origRef, desc, err := p.resolver.Resolve(ctx, ref.String())
 			origRef, desc, err := p.resolver.Resolve(ctx, ref.String())
 			if err != nil {
 			if err != nil {
 				p.resolveErr = err
 				p.resolveErr = err
-				resolveProgressDone(err)
+				_ = resolveProgressDone(err)
 				return
 				return
 			}
 			}
 
 
@@ -300,19 +300,19 @@ func (p *puller) resolve(ctx context.Context) error {
 			ref, err := distreference.WithDigest(ref, p.desc.Digest)
 			ref, err := distreference.WithDigest(ref, p.desc.Digest)
 			if err != nil {
 			if err != nil {
 				p.resolveErr = err
 				p.resolveErr = err
-				resolveProgressDone(err)
+				_ = resolveProgressDone(err)
 				return
 				return
 			}
 			}
 			_, dt, err := p.is.ResolveImageConfig(ctx, ref.String(), gw.ResolveImageConfigOpt{Platform: &p.platform, ResolveMode: resolveModeToString(p.src.ResolveMode)}, p.sm)
 			_, dt, err := p.is.ResolveImageConfig(ctx, ref.String(), gw.ResolveImageConfigOpt{Platform: &p.platform, ResolveMode: resolveModeToString(p.src.ResolveMode)}, p.sm)
 			if err != nil {
 			if err != nil {
 				p.resolveErr = err
 				p.resolveErr = err
-				resolveProgressDone(err)
+				_ = resolveProgressDone(err)
 				return
 				return
 			}
 			}
 
 
 			p.config = dt
 			p.config = dt
 		}
 		}
-		resolveProgressDone(nil)
+		_ = resolveProgressDone(nil)
 	})
 	})
 	return p.resolveErr
 	return p.resolveErr
 }
 }
@@ -509,7 +509,7 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
 						tm := time.Now()
 						tm := time.Now()
 						end = &tm
 						end = &tm
 					}
 					}
-					pw.Write("extracting "+p.ID, progress.Status{
+					_ = pw.Write("extracting "+p.ID, progress.Status{
 						Action:    "extract",
 						Action:    "extract",
 						Started:   &st.st,
 						Started:   &st.st,
 						Completed: end,
 						Completed: end,
@@ -672,7 +672,7 @@ func showProgress(ctx context.Context, ongoing *jobs, cs content.Store, pw progr
 			refKey := remotes.MakeRefKey(ctx, j.Descriptor)
 			refKey := remotes.MakeRefKey(ctx, j.Descriptor)
 			if a, ok := actives[refKey]; ok {
 			if a, ok := actives[refKey]; ok {
 				started := j.started
 				started := j.started
-				pw.Write(j.Digest.String(), progress.Status{
+				_ = pw.Write(j.Digest.String(), progress.Status{
 					Action:  a.Status,
 					Action:  a.Status,
 					Total:   int(a.Total),
 					Total:   int(a.Total),
 					Current: int(a.Offset),
 					Current: int(a.Offset),
@@ -685,7 +685,7 @@ func showProgress(ctx context.Context, ongoing *jobs, cs content.Store, pw progr
 				info, err := cs.Info(context.TODO(), j.Digest)
 				info, err := cs.Info(context.TODO(), j.Digest)
 				if err != nil {
 				if err != nil {
 					if containerderrors.IsNotFound(err) {
 					if containerderrors.IsNotFound(err) {
-						// pw.Write(j.Digest.String(), progress.Status{
+						// _ = pw.Write(j.Digest.String(), progress.Status{
 						// 	Action: "waiting",
 						// 	Action: "waiting",
 						// })
 						// })
 						continue
 						continue
@@ -697,7 +697,7 @@ func showProgress(ctx context.Context, ongoing *jobs, cs content.Store, pw progr
 				if done || j.done {
 				if done || j.done {
 					started := j.started
 					started := j.started
 					createdAt := info.CreatedAt
 					createdAt := info.CreatedAt
-					pw.Write(j.Digest.String(), progress.Status{
+					_ = pw.Write(j.Digest.String(), progress.Status{
 						Action:    "done",
 						Action:    "done",
 						Current:   int(info.Size),
 						Current:   int(info.Size),
 						Total:     int(info.Size),
 						Total:     int(info.Size),
@@ -783,13 +783,13 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
 	st := progress.Status{
 	st := progress.Status{
 		Started: &now,
 		Started: &now,
 	}
 	}
-	pw.Write(id, st)
+	_ = pw.Write(id, st)
 	return func(err error) error {
 	return func(err error) error {
 		// TODO: set error on status
 		// TODO: set error on status
 		now := time.Now()
 		now := time.Now()
 		st.Completed = &now
 		st.Completed = &now
-		pw.Write(id, st)
-		pw.Close()
+		_ = pw.Write(id, st)
+		_ = pw.Close()
 		return err
 		return err
 	}
 	}
 }
 }

+ 3 - 3
builder/builder-next/exporter/export.go

@@ -130,7 +130,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source)
 			diffs[i] = digest.Digest(diffIDs[i])
 			diffs[i] = digest.Digest(diffIDs[i])
 		}
 		}
 
 
-		layersDone(nil)
+		_ = layersDone(nil)
 	}
 	}
 
 
 	if len(config) == 0 {
 	if len(config) == 0 {
@@ -160,7 +160,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source)
 	if err != nil {
 	if err != nil {
 		return nil, configDone(err)
 		return nil, configDone(err)
 	}
 	}
-	configDone(nil)
+	_ = configDone(nil)
 
 
 	if e.opt.ReferenceStore != nil {
 	if e.opt.ReferenceStore != nil {
 		for _, targetName := range e.targetNames {
 		for _, targetName := range e.targetNames {
@@ -169,7 +169,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source)
 			if err := e.opt.ReferenceStore.AddTag(targetName, digest.Digest(id), true); err != nil {
 			if err := e.opt.ReferenceStore.AddTag(targetName, digest.Digest(id), true); err != nil {
 				return nil, tagDone(err)
 				return nil, tagDone(err)
 			}
 			}
-			tagDone(nil)
+			_ = tagDone(nil)
 		}
 		}
 	}
 	}
 
 

+ 5 - 5
builder/builder-next/exporter/writer.go

@@ -78,9 +78,9 @@ func patchImageConfig(dt []byte, dps []digest.Digest, history []ocispec.History,
 	}
 	}
 
 
 	if cache != nil {
 	if cache != nil {
-		dt, err := json.Marshal(cache)
+		dt, err = json.Marshal(cache)
 		if err != nil {
 		if err != nil {
-			return nil, err
+			return nil, errors.Wrap(err, "failed to marshal cache")
 		}
 		}
 		m["moby.buildkit.cache.v0"] = dt
 		m["moby.buildkit.cache.v0"] = dt
 	}
 	}
@@ -204,13 +204,13 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
 	st := progress.Status{
 	st := progress.Status{
 		Started: &now,
 		Started: &now,
 	}
 	}
-	pw.Write(id, st)
+	_ = pw.Write(id, st)
 	return func(err error) error {
 	return func(err error) error {
 		// TODO: set error on status
 		// TODO: set error on status
 		now := time.Now()
 		now := time.Now()
 		st.Completed = &now
 		st.Completed = &now
-		pw.Write(id, st)
-		pw.Close()
+		_ = pw.Write(id, st)
+		_ = pw.Close()
 		return err
 		return err
 	}
 	}
 }
 }

+ 4 - 4
builder/builder-next/worker/worker.go

@@ -394,7 +394,7 @@ func (ld *layerDescriptor) Download(ctx context.Context, progressOutput pkgprogr
 	if err := contentutil.Copy(ctx, ld.w.ContentStore, ld.provider, ld.desc); err != nil {
 	if err := contentutil.Copy(ctx, ld.w.ContentStore, ld.provider, ld.desc); err != nil {
 		return nil, 0, done(err)
 		return nil, 0, done(err)
 	}
 	}
-	done(nil)
+	_ = done(nil)
 
 
 	ra, err := ld.w.ContentStore.ReaderAt(ctx, ld.desc)
 	ra, err := ld.w.ContentStore.ReaderAt(ctx, ld.desc)
 	if err != nil {
 	if err != nil {
@@ -443,13 +443,13 @@ func oneOffProgress(ctx context.Context, id string) func(err error) error {
 	st := progress.Status{
 	st := progress.Status{
 		Started: &now,
 		Started: &now,
 	}
 	}
-	pw.Write(id, st)
+	_ = pw.Write(id, st)
 	return func(err error) error {
 	return func(err error) error {
 		// TODO: set error on status
 		// TODO: set error on status
 		now := time.Now()
 		now := time.Now()
 		st.Completed = &now
 		st.Completed = &now
-		pw.Write(id, st)
-		pw.Close()
+		_ = pw.Write(id, st)
+		_ = pw.Close()
 		return err
 		return err
 	}
 	}
 }
 }

+ 1 - 1
builder/dockerfile/copy_unix.go

@@ -25,7 +25,7 @@ func fixPermissions(source, destination string, identity idtools.Identity, overr
 
 
 	// We Walk on the source rather than on the destination because we don't
 	// We Walk on the source rather than on the destination because we don't
 	// want to change permissions on things we haven't created or modified.
 	// want to change permissions on things we haven't created or modified.
-	return filepath.Walk(source, func(fullpath string, info os.FileInfo, err error) error {
+	return filepath.Walk(source, func(fullpath string, _ os.FileInfo, _ error) error {
 		// Do not alter the walk root iff. it existed before, as it doesn't fall under
 		// Do not alter the walk root iff. it existed before, as it doesn't fall under
 		// the domain of "things we should chown".
 		// the domain of "things we should chown".
 		if skipChownRoot && source == fullpath {
 		if skipChownRoot && source == fullpath {

+ 1 - 1
builder/dockerfile/copy_windows.go

@@ -6,7 +6,7 @@ import (
 	"path/filepath"
 	"path/filepath"
 	"strings"
 	"strings"
 
 
-	"github.com/Microsoft/go-winio"
+	winio "github.com/Microsoft/go-winio"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/reexec"
 	"github.com/docker/docker/pkg/reexec"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"

+ 2 - 3
builder/dockerfile/imagecontext.go

@@ -88,9 +88,8 @@ func (m *imageSources) Add(im *imageMount) {
 
 
 // imageMount is a reference to an image that can be used as a builder.Source
 // imageMount is a reference to an image that can be used as a builder.Source
 type imageMount struct {
 type imageMount struct {
-	image  builder.Image
-	source builder.Source
-	layer  builder.ROLayer
+	image builder.Image
+	layer builder.ROLayer
 }
 }
 
 
 func newImageMount(image builder.Image, layer builder.ROLayer) *imageMount {
 func newImageMount(image builder.Image, layer builder.ROLayer) *imageMount {

+ 1 - 1
builder/dockerfile/metrics.go

@@ -1,7 +1,7 @@
 package dockerfile // import "github.com/docker/docker/builder/dockerfile"
 package dockerfile // import "github.com/docker/docker/builder/dockerfile"
 
 
 import (
 import (
-	"github.com/docker/go-metrics"
+	metrics "github.com/docker/go-metrics"
 )
 )
 
 
 var (
 var (

+ 1 - 0
builder/fscache/fscache.go

@@ -497,6 +497,7 @@ type sourceMeta struct {
 	Size        int64
 	Size        int64
 }
 }
 
 
+//nolint:structcheck
 type cachedSource struct {
 type cachedSource struct {
 	sourceMeta
 	sourceMeta
 	refs    map[*cachedSourceRef]struct{}
 	refs    map[*cachedSourceRef]struct{}

+ 2 - 2
builder/remotecontext/git/gitutils.go

@@ -142,9 +142,9 @@ func supportsShallowClone(remoteURL string) bool {
 		serviceURL := remoteURL + "/info/refs?service=git-upload-pack"
 		serviceURL := remoteURL + "/info/refs?service=git-upload-pack"
 
 
 		// Try a HEAD request and fallback to a Get request on error
 		// Try a HEAD request and fallback to a Get request on error
-		res, err := http.Head(serviceURL)
+		res, err := http.Head(serviceURL) // #nosec G107
 		if err != nil || res.StatusCode != http.StatusOK {
 		if err != nil || res.StatusCode != http.StatusOK {
-			res, err = http.Get(serviceURL)
+			res, err = http.Get(serviceURL) // #nosec G107
 			if err == nil {
 			if err == nil {
 				res.Body.Close()
 				res.Body.Close()
 			}
 			}

+ 1 - 0
builder/remotecontext/remote.go

@@ -45,6 +45,7 @@ func downloadRemote(remoteURL string) (string, io.ReadCloser, error) {
 // GetWithStatusError does an http.Get() and returns an error if the
 // GetWithStatusError does an http.Get() and returns an error if the
 // status code is 4xx or 5xx.
 // status code is 4xx or 5xx.
 func GetWithStatusError(address string) (resp *http.Response, err error) {
 func GetWithStatusError(address string) (resp *http.Response, err error) {
+	// #nosec G107
 	if resp, err = http.Get(address); err != nil {
 	if resp, err = http.Get(address); err != nil {
 		if uerr, ok := err.(*url.Error); ok {
 		if uerr, ok := err.(*url.Error); ok {
 			if derr, ok := uerr.Err.(*net.DNSError); ok && !derr.IsTimeout {
 			if derr, ok := uerr.Err.(*net.DNSError); ok && !derr.IsTimeout {

+ 1 - 1
builder/remotecontext/tarsum.go

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

+ 1 - 0
client/container_list.go

@@ -35,6 +35,7 @@ func (cli *Client) ContainerList(ctx context.Context, options types.ContainerLis
 	}
 	}
 
 
 	if options.Filters.Len() > 0 {
 	if options.Filters.Len() > 0 {
+		//lint:ignore SA1019 for old code
 		filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
 		filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
 
 
 		if err != nil {
 		if err != nil {

+ 1 - 0
client/events.go

@@ -90,6 +90,7 @@ func buildEventsQueryParams(cliVersion string, options types.EventsOptions) (url
 	}
 	}
 
 
 	if options.Filters.Len() > 0 {
 	if options.Filters.Len() > 0 {
+		//lint:ignore SA1019 for old code
 		filterJSON, err := filters.ToParamWithVersion(cliVersion, options.Filters)
 		filterJSON, err := filters.ToParamWithVersion(cliVersion, options.Filters)
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err

+ 2 - 0
client/hijack.go

@@ -87,6 +87,8 @@ func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto
 
 
 	// Server hijacks the connection, error 'connection closed' expected
 	// Server hijacks the connection, error 'connection closed' expected
 	resp, err := clientconn.Do(req)
 	resp, err := clientconn.Do(req)
+
+	//lint:ignore SA1019 for connecting to old (pre go1.8) daemons
 	if err != httputil.ErrPersistEOF {
 	if err != httputil.ErrPersistEOF {
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err

+ 1 - 1
client/image_build_test.go

@@ -13,7 +13,7 @@ import (
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 )
 )
 
 
 func TestImageBuildError(t *testing.T) {
 func TestImageBuildError(t *testing.T) {

+ 1 - 0
client/image_list.go

@@ -24,6 +24,7 @@ func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions
 		}
 		}
 	}
 	}
 	if optionFilters.Len() > 0 {
 	if optionFilters.Len() > 0 {
+		//lint:ignore SA1019 for old code
 		filterJSON, err := filters.ToParamWithVersion(cli.version, optionFilters)
 		filterJSON, err := filters.ToParamWithVersion(cli.version, optionFilters)
 		if err != nil {
 		if err != nil {
 			return images, err
 			return images, err

+ 1 - 0
client/network_list.go

@@ -13,6 +13,7 @@ import (
 func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
 func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
 	query := url.Values{}
 	query := url.Values{}
 	if options.Filters.Len() > 0 {
 	if options.Filters.Len() > 0 {
+		//lint:ignore SA1019 for old code
 		filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
 		filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
 		if err != nil {
 		if err != nil {
 			return nil, err
 			return nil, err

+ 1 - 0
client/plugin_list.go

@@ -15,6 +15,7 @@ func (cli *Client) PluginList(ctx context.Context, filter filters.Args) (types.P
 	query := url.Values{}
 	query := url.Values{}
 
 
 	if filter.Len() > 0 {
 	if filter.Len() > 0 {
+		//lint:ignore SA1019 for old code
 		filterJSON, err := filters.ToParamWithVersion(cli.version, filter)
 		filterJSON, err := filters.ToParamWithVersion(cli.version, filter)
 		if err != nil {
 		if err != nil {
 			return plugins, err
 			return plugins, err

+ 0 - 9
client/request.go

@@ -50,15 +50,6 @@ func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, b
 	return cli.sendRequest(ctx, "POST", path, query, body, headers)
 	return cli.sendRequest(ctx, "POST", path, query, body, headers)
 }
 }
 
 
-// put sends an http request to the docker API using the method PUT.
-func (cli *Client) put(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (serverResponse, error) {
-	body, headers, err := encodeBody(obj, headers)
-	if err != nil {
-		return serverResponse{}, err
-	}
-	return cli.sendRequest(ctx, "PUT", path, query, body, headers)
-}
-
 // putRaw sends an http request to the docker API using the method PUT.
 // putRaw sends an http request to the docker API using the method PUT.
 func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
 func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
 	return cli.sendRequest(ctx, "PUT", path, query, body, headers)
 	return cli.sendRequest(ctx, "PUT", path, query, body, headers)

+ 1 - 1
client/service_create.go

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

+ 2 - 2
client/service_create_test.go

@@ -14,8 +14,8 @@ import (
 	registrytypes "github.com/docker/docker/api/types/registry"
 	registrytypes "github.com/docker/docker/api/types/registry"
 	"github.com/docker/docker/api/types/swarm"
 	"github.com/docker/docker/api/types/swarm"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
-	"github.com/opencontainers/go-digest"
-	"github.com/opencontainers/image-spec/specs-go/v1"
+	digest "github.com/opencontainers/go-digest"
+	v1 "github.com/opencontainers/image-spec/specs-go/v1"
 	"gotest.tools/assert"
 	"gotest.tools/assert"
 	is "gotest.tools/assert/cmp"
 	is "gotest.tools/assert/cmp"
 )
 )

+ 1 - 0
client/volume_list.go

@@ -15,6 +15,7 @@ func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumet
 	query := url.Values{}
 	query := url.Values{}
 
 
 	if filter.Len() > 0 {
 	if filter.Len() > 0 {
+		//lint:ignore SA1019 for old code
 		filterJSON, err := filters.ToParamWithVersion(cli.version, filter)
 		filterJSON, err := filters.ToParamWithVersion(cli.version, filter)
 		if err != nil {
 		if err != nil {
 			return volumes, err
 			return volumes, err

+ 3 - 3
cmd/dockerd/config.go

@@ -47,12 +47,12 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
 
 
 	// "--graph" is "soft-deprecated" in favor of "data-root". This flag was added
 	// "--graph" is "soft-deprecated" in favor of "data-root". This flag was added
 	// before Docker 1.0, so won't be removed, only hidden, to discourage its usage.
 	// before Docker 1.0, so won't be removed, only hidden, to discourage its usage.
-	flags.MarkHidden("graph")
+	_ = flags.MarkHidden("graph")
 
 
 	flags.StringVar(&conf.Root, "data-root", defaultDataRoot, "Root directory of persistent Docker state")
 	flags.StringVar(&conf.Root, "data-root", defaultDataRoot, "Root directory of persistent Docker state")
 
 
 	flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
 	flags.BoolVarP(&conf.AutoRestart, "restart", "r", true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
-	flags.MarkDeprecated("restart", "Please use a restart policy on docker run")
+	_ = flags.MarkDeprecated("restart", "Please use a restart policy on docker run")
 
 
 	// Windows doesn't support setting the storage driver - there is no choice as to which ones to use.
 	// Windows doesn't support setting the storage driver - there is no choice as to which ones to use.
 	if runtime.GOOS != "windows" {
 	if runtime.GOOS != "windows" {
@@ -75,7 +75,7 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error {
 	flags.IntVar(&maxConcurrentUploads, "max-concurrent-uploads", config.DefaultMaxConcurrentUploads, "Set the max concurrent uploads for each push")
 	flags.IntVar(&maxConcurrentUploads, "max-concurrent-uploads", config.DefaultMaxConcurrentUploads, "Set the max concurrent uploads for each push")
 	flags.IntVar(&conf.ShutdownTimeout, "shutdown-timeout", defaultShutdownTimeout, "Set the default shutdown timeout")
 	flags.IntVar(&conf.ShutdownTimeout, "shutdown-timeout", defaultShutdownTimeout, "Set the default shutdown timeout")
 	flags.IntVar(&conf.NetworkDiagnosticPort, "network-diagnostic-port", 0, "TCP port number of the network diagnostic server")
 	flags.IntVar(&conf.NetworkDiagnosticPort, "network-diagnostic-port", 0, "TCP port number of the network diagnostic server")
-	flags.MarkHidden("network-diagnostic-port")
+	_ = flags.MarkHidden("network-diagnostic-port")
 
 
 	flags.StringVar(&conf.SwarmDefaultAdvertiseAddr, "swarm-default-advertise-addr", "", "Set default address or interface for swarm advertised address")
 	flags.StringVar(&conf.SwarmDefaultAdvertiseAddr, "swarm-default-advertise-addr", "", "Set default address or interface for swarm advertised address")
 	flags.BoolVar(&conf.Experimental, "experimental", false, "Enable experimental features")
 	flags.BoolVar(&conf.Experimental, "experimental", false, "Enable experimental features")

+ 1 - 1
cmd/dockerd/config_unix.go

@@ -8,7 +8,7 @@ import (
 	"github.com/docker/docker/daemon/config"
 	"github.com/docker/docker/daemon/config"
 	"github.com/docker/docker/opts"
 	"github.com/docker/docker/opts"
 	"github.com/docker/docker/rootless"
 	"github.com/docker/docker/rootless"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/spf13/pflag"
 	"github.com/spf13/pflag"
 )
 )

+ 1 - 1
cmd/dockerd/metrics.go

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

+ 1 - 1
cmd/dockerd/service_windows.go

@@ -52,7 +52,7 @@ func installServiceFlags(flags *pflag.FlagSet) {
 	flRegisterService = flags.Bool("register-service", false, "Register the service and exit")
 	flRegisterService = flags.Bool("register-service", false, "Register the service and exit")
 	flUnregisterService = flags.Bool("unregister-service", false, "Unregister the service and exit")
 	flUnregisterService = flags.Bool("unregister-service", false, "Unregister the service and exit")
 	flRunService = flags.Bool("run-service", false, "")
 	flRunService = flags.Bool("run-service", false, "")
-	flags.MarkHidden("run-service")
+	_ = flags.MarkHidden("run-service")
 }
 }
 
 
 type handler struct {
 type handler struct {

+ 1 - 1
container/container.go

@@ -36,7 +36,7 @@ import (
 	"github.com/docker/docker/restartmanager"
 	"github.com/docker/docker/restartmanager"
 	"github.com/docker/docker/volume"
 	"github.com/docker/docker/volume"
 	volumemounts "github.com/docker/docker/volume/mounts"
 	volumemounts "github.com/docker/docker/volume/mounts"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	agentexec "github.com/docker/swarmkit/agent/exec"
 	agentexec "github.com/docker/swarmkit/agent/exec"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"

+ 1 - 1
container/state.go

@@ -8,7 +8,7 @@ import (
 	"time"
 	"time"
 
 
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 )
 )
 
 
 // State holds the current container state, and has methods to get and
 // State holds the current container state, and has methods to get and

+ 1 - 1
container/view.go

@@ -9,7 +9,7 @@ import (
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/network"
 	"github.com/docker/docker/api/types/network"
 	"github.com/docker/go-connections/nat"
 	"github.com/docker/go-connections/nat"
-	"github.com/hashicorp/go-memdb"
+	memdb "github.com/hashicorp/go-memdb"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 

+ 1 - 1
contrib/docker-device-tool/device_tool.go

@@ -38,7 +38,7 @@ func byteSizeFromString(arg string) (int64, error) {
 
 
 	rest = strings.ToLower(strings.TrimSpace(rest))
 	rest = strings.ToLower(strings.TrimSpace(rest))
 
 
-	var multiplier int64 = 1
+	var multiplier int64
 	switch rest {
 	switch rest {
 	case "":
 	case "":
 		multiplier = 1
 		multiplier = 1

+ 3 - 3
daemon/checkpoint.go

@@ -35,16 +35,16 @@ func getCheckpointDir(checkDir, checkpointID, ctrName, ctrID, ctrCheckpointDir s
 			err2 = os.MkdirAll(checkpointAbsDir, 0700)
 			err2 = os.MkdirAll(checkpointAbsDir, 0700)
 		case err != nil:
 		case err != nil:
 			err2 = err
 			err2 = err
-		case err == nil:
+		default:
 			err2 = fmt.Errorf("%s exists and is not a directory", checkpointAbsDir)
 			err2 = fmt.Errorf("%s exists and is not a directory", checkpointAbsDir)
 		}
 		}
 	} else {
 	} else {
 		switch {
 		switch {
 		case err != nil:
 		case err != nil:
 			err2 = fmt.Errorf("checkpoint %s does not exist for container %s", checkpointID, ctrName)
 			err2 = fmt.Errorf("checkpoint %s does not exist for container %s", checkpointID, ctrName)
-		case err == nil && stat.IsDir():
+		case stat.IsDir():
 			err2 = nil
 			err2 = nil
-		case err == nil:
+		default:
 			err2 = fmt.Errorf("%s exists and is not a directory", checkpointAbsDir)
 			err2 = fmt.Errorf("%s exists and is not a directory", checkpointAbsDir)
 		}
 		}
 	}
 	}

+ 1 - 2
daemon/cluster/controllers/plugin/controller.go

@@ -11,7 +11,7 @@ import (
 	"github.com/docker/docker/api/types/swarm/runtime"
 	"github.com/docker/docker/api/types/swarm/runtime"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/plugin"
 	"github.com/docker/docker/plugin"
-	"github.com/docker/docker/plugin/v2"
+	v2 "github.com/docker/docker/plugin/v2"
 	"github.com/docker/swarmkit/api"
 	"github.com/docker/swarmkit/api"
 	"github.com/gogo/protobuf/proto"
 	"github.com/gogo/protobuf/proto"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
@@ -34,7 +34,6 @@ type Controller struct {
 
 
 	pluginID  string
 	pluginID  string
 	serviceID string
 	serviceID string
-	taskID    string
 
 
 	// hook used to signal tests that `Wait()` is actually ready and waiting
 	// hook used to signal tests that `Wait()` is actually ready and waiting
 	signalWaitReady func()
 	signalWaitReady func()

+ 1 - 1
daemon/cluster/controllers/plugin/controller_test.go

@@ -15,7 +15,7 @@ import (
 	"github.com/docker/docker/api/types/swarm/runtime"
 	"github.com/docker/docker/api/types/swarm/runtime"
 	"github.com/docker/docker/pkg/pubsub"
 	"github.com/docker/docker/pkg/pubsub"
 	"github.com/docker/docker/plugin"
 	"github.com/docker/docker/plugin"
-	"github.com/docker/docker/plugin/v2"
+	v2 "github.com/docker/docker/plugin/v2"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 

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

@@ -26,7 +26,7 @@ import (
 	"github.com/docker/swarmkit/api"
 	"github.com/docker/swarmkit/api"
 	"github.com/docker/swarmkit/log"
 	"github.com/docker/swarmkit/log"
 	gogotypes "github.com/gogo/protobuf/types"
 	gogotypes "github.com/gogo/protobuf/types"
-	"github.com/opencontainers/go-digest"
+	digest "github.com/opencontainers/go-digest"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/time/rate"
 	"golang.org/x/time/rate"

+ 0 - 4
daemon/cluster/executor/container/container.go

@@ -98,10 +98,6 @@ func (c *containerConfig) taskID() string {
 	return c.task.ID
 	return c.task.ID
 }
 }
 
 
-func (c *containerConfig) endpoint() *api.Endpoint {
-	return c.task.Endpoint
-}
-
 func (c *containerConfig) spec() *api.ContainerSpec {
 func (c *containerConfig) spec() *api.ContainerSpec {
 	return c.task.Spec.GetContainer()
 	return c.task.Spec.GetContainer()
 }
 }

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

@@ -637,7 +637,7 @@ func parsePortMap(portMap nat.PortMap) ([]*api.PortConfig, error) {
 			return nil, err
 			return nil, err
 		}
 		}
 
 
-		protocol := api.ProtocolTCP
+		var protocol api.PortConfig_Protocol
 		switch strings.ToLower(parts[1]) {
 		switch strings.ToLower(parts[1]) {
 		case "tcp":
 		case "tcp":
 			protocol = api.ProtocolTCP
 			protocol = api.ProtocolTCP

+ 1 - 1
daemon/cluster/nodes.go

@@ -66,7 +66,7 @@ func (c *Cluster) GetNode(input string) (types.Node, error) {
 
 
 // UpdateNode updates existing nodes properties.
 // UpdateNode updates existing nodes properties.
 func (c *Cluster) UpdateNode(input string, version uint64, spec types.NodeSpec) error {
 func (c *Cluster) UpdateNode(input string, version uint64, spec types.NodeSpec) error {
-	return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
+	return c.lockedManagerAction(func(_ context.Context, state nodeState) error {
 		nodeSpec, err := convert.NodeSpecToGRPC(spec)
 		nodeSpec, err := convert.NodeSpecToGRPC(spec)
 		if err != nil {
 		if err != nil {
 			return errdefs.InvalidParameter(err)
 			return errdefs.InvalidParameter(err)

+ 1 - 1
daemon/config/config_unix.go

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

+ 1 - 1
daemon/config/config_unix_test.go

@@ -6,7 +6,7 @@ import (
 	"testing"
 	"testing"
 
 
 	"github.com/docker/docker/opts"
 	"github.com/docker/docker/opts"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	"github.com/spf13/pflag"
 	"github.com/spf13/pflag"
 	"gotest.tools/assert"
 	"gotest.tools/assert"
 	is "gotest.tools/assert/cmp"
 	is "gotest.tools/assert/cmp"

+ 1 - 1
daemon/events/metrics.go

@@ -1,6 +1,6 @@
 package events // import "github.com/docker/docker/daemon/events"
 package events // import "github.com/docker/docker/daemon/events"
 
 
-import "github.com/docker/go-metrics"
+import metrics "github.com/docker/go-metrics"
 
 
 var (
 var (
 	eventsCounter    metrics.Counter
 	eventsCounter    metrics.Counter

+ 1 - 1
daemon/exec.go

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

+ 1 - 1
daemon/exec_linux.go

@@ -7,7 +7,7 @@ import (
 	"github.com/docker/docker/daemon/exec"
 	"github.com/docker/docker/daemon/exec"
 	"github.com/docker/docker/oci/caps"
 	"github.com/docker/docker/oci/caps"
 	"github.com/opencontainers/runc/libcontainer/apparmor"
 	"github.com/opencontainers/runc/libcontainer/apparmor"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 )
 )
 
 
 func (daemon *Daemon) execSetPlatformOpt(c *container.Container, ec *exec.Config, p *specs.Process) error {
 func (daemon *Daemon) execSetPlatformOpt(c *container.Container, ec *exec.Config, p *specs.Process) error {

+ 1 - 1
daemon/exec_linux_test.go

@@ -9,7 +9,7 @@ import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/daemon/exec"
 	"github.com/docker/docker/daemon/exec"
 	"github.com/opencontainers/runc/libcontainer/apparmor"
 	"github.com/opencontainers/runc/libcontainer/apparmor"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 	"gotest.tools/assert"
 	"gotest.tools/assert"
 )
 )
 
 

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

@@ -32,7 +32,7 @@ import (
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"

+ 0 - 3
daemon/graphdriver/copy/copy.go

@@ -133,9 +133,6 @@ func DirCopy(srcDir, dstDir string, copyMode Mode, copyXattrs bool) error {
 		}
 		}
 
 
 		dstPath := filepath.Join(dstDir, relPath)
 		dstPath := filepath.Join(dstDir, relPath)
-		if err != nil {
-			return err
-		}
 
 
 		stat, ok := f.Sys().(*syscall.Stat_t)
 		stat, ok := f.Sys().(*syscall.Stat_t)
 		if !ok {
 		if !ok {

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

@@ -27,7 +27,7 @@ import (
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/kernel"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"

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

@@ -40,7 +40,7 @@ func initLoopbacks() error {
 		// only create new loopback files if they don't exist
 		// only create new loopback files if they don't exist
 		if _, err := os.Stat(loopPath); err != nil {
 		if _, err := os.Stat(loopPath); err != nil {
 			if mkerr := syscall.Mknod(loopPath,
 			if mkerr := syscall.Mknod(loopPath,
-				uint32(statT.Mode|syscall.S_IFBLK), int((7<<8)|(i&0xff)|((i&0xfff00)<<12))); mkerr != nil {
+				uint32(statT.Mode|syscall.S_IFBLK), int((7<<8)|(i&0xff)|((i&0xfff00)<<12))); mkerr != nil { // nolint: unconvert
 				return mkerr
 				return mkerr
 			}
 			}
 			os.Chown(loopPath, int(statT.Uid), int(statT.Gid))
 			os.Chown(loopPath, int(statT.Uid), int(statT.Gid))

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

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

+ 4 - 0
daemon/graphdriver/graphtest/graphbench_unix.go

@@ -172,6 +172,10 @@ func DriverBenchDiffApplyN(b *testing.B, fileCount int, drivername string, drive
 		b.StopTimer()
 		b.StopTimer()
 		arch.Close()
 		arch.Close()
 
 
+		// suppressing "SA9003: empty branch (staticcheck)" instead of commenting-out/removing
+		// these lines because removing/commenting these lines causes a ripple effect
+		// of changes, and there's still a to-do below
+		//nolint:staticcheck
 		if applyDiffSize != diffSize {
 		if applyDiffSize != diffSize {
 			// TODO: enforce this
 			// TODO: enforce this
 			//b.Fatalf("Apply diff size different, got %d, expected %s", applyDiffSize, diffSize)
 			//b.Fatalf("Apply diff size different, got %d, expected %s", applyDiffSize, diffSize)

+ 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"
 	"github.com/docker/docker/daemon/graphdriver/quota"
 	"github.com/docker/docker/daemon/graphdriver/quota"
 	"github.com/docker/docker/pkg/stringid"
 	"github.com/docker/docker/pkg/stringid"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"
 	"gotest.tools/assert"
 	"gotest.tools/assert"
 	is "gotest.tools/assert/cmp"
 	is "gotest.tools/assert/cmp"

+ 1 - 1
daemon/graphdriver/overlay2/overlay.go

@@ -31,7 +31,7 @@ import (
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	rsystem "github.com/opencontainers/runc/libcontainer/system"
 	rsystem "github.com/opencontainers/runc/libcontainer/system"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/opencontainers/selinux/go-selinux/label"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"

+ 1 - 1
daemon/graphdriver/plugin.go

@@ -7,7 +7,7 @@ import (
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/pkg/plugins"
 	"github.com/docker/docker/pkg/plugins"
-	"github.com/docker/docker/plugin/v2"
+	v2 "github.com/docker/docker/plugin/v2"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 )
 )
 
 

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

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

+ 1 - 0
daemon/graphdriver/vfs/quota_linux.go

@@ -5,6 +5,7 @@ import (
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 
+//nolint:structcheck
 type driverQuota struct {
 type driverQuota struct {
 	quotaCtl *quota.Control
 	quotaCtl *quota.Control
 	quotaOpt quota.Quota
 	quotaOpt quota.Quota

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

@@ -19,7 +19,7 @@ import (
 	"time"
 	"time"
 	"unsafe"
 	"unsafe"
 
 
-	"github.com/Microsoft/go-winio"
+	winio "github.com/Microsoft/go-winio"
 	"github.com/Microsoft/go-winio/archive/tar"
 	"github.com/Microsoft/go-winio/archive/tar"
 	"github.com/Microsoft/go-winio/backuptar"
 	"github.com/Microsoft/go-winio/backuptar"
 	"github.com/Microsoft/go-winio/vhd"
 	"github.com/Microsoft/go-winio/vhd"

+ 1 - 1
daemon/images/image_prune.go

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

+ 1 - 1
daemon/images/image_pull.go

@@ -14,7 +14,7 @@ import (
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/pkg/progress"
 	"github.com/docker/docker/pkg/progress"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
-	"github.com/opencontainers/go-digest"
+	digest "github.com/opencontainers/go-digest"
 	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 )
 
 

+ 1 - 1
daemon/images/locals.go

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

+ 1 - 1
daemon/images/service.go

@@ -15,7 +15,7 @@ import (
 	dockerreference "github.com/docker/docker/reference"
 	dockerreference "github.com/docker/docker/reference"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/libtrust"
 	"github.com/docker/libtrust"
-	"github.com/opencontainers/go-digest"
+	digest "github.com/opencontainers/go-digest"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )

+ 1 - 1
daemon/info.go

@@ -21,7 +21,7 @@ import (
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/go-connections/sockets"
 	"github.com/docker/go-connections/sockets"
-	"github.com/docker/go-metrics"
+	metrics "github.com/docker/go-metrics"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 

+ 2 - 2
daemon/info_unix_test.go

@@ -39,7 +39,7 @@ func TestParseInitVersion(t *testing.T) {
 	}
 	}
 
 
 	for _, test := range tests {
 	for _, test := range tests {
-		version, commit, err := parseInitVersion(string(test.output))
+		version, commit, err := parseInitVersion(test.output)
 		if test.invalid {
 		if test.invalid {
 			assert.Check(t, is.ErrorContains(err, ""))
 			assert.Check(t, is.ErrorContains(err, ""))
 		} else {
 		} else {
@@ -91,7 +91,7 @@ spec: 1.0.0
 	}
 	}
 
 
 	for _, test := range tests {
 	for _, test := range tests {
-		version, commit, err := parseRuncVersion(string(test.output))
+		version, commit, err := parseRuncVersion(test.output)
 		if test.invalid {
 		if test.invalid {
 			assert.Check(t, is.ErrorContains(err, ""))
 			assert.Check(t, is.ErrorContains(err, ""))
 		} else {
 		} else {

+ 1 - 1
daemon/list_test.go

@@ -12,7 +12,7 @@ import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
 	"github.com/google/uuid"
 	"github.com/google/uuid"
-	"github.com/opencontainers/go-digest"
+	digest "github.com/opencontainers/go-digest"
 	"gotest.tools/assert"
 	"gotest.tools/assert"
 	is "gotest.tools/assert/cmp"
 	is "gotest.tools/assert/cmp"
 )
 )

+ 1 - 1
daemon/listeners/listeners_windows.go

@@ -6,7 +6,7 @@ import (
 	"net"
 	"net"
 	"strings"
 	"strings"
 
 
-	"github.com/Microsoft/go-winio"
+	winio "github.com/Microsoft/go-winio"
 	"github.com/docker/go-connections/sockets"
 	"github.com/docker/go-connections/sockets"
 )
 )
 
 

+ 2 - 3
daemon/logger/copier_test.go

@@ -3,7 +3,6 @@ package logger // import "github.com/docker/docker/daemon/logger"
 import (
 import (
 	"bytes"
 	"bytes"
 	"encoding/json"
 	"encoding/json"
-	"fmt"
 	"io"
 	"io"
 	"os"
 	"os"
 	"strings"
 	"strings"
@@ -453,9 +452,9 @@ func piped(b *testing.B, iterations int, delay time.Duration, buf []byte) io.Rea
 			time.Sleep(delay)
 			time.Sleep(delay)
 			if n, err := w.Write(buf); err != nil || n != len(buf) {
 			if n, err := w.Write(buf); err != nil || n != len(buf) {
 				if err != nil {
 				if err != nil {
-					b.Fatal(err)
+					b.Error(err)
 				}
 				}
-				b.Fatal(fmt.Errorf("short write"))
+				b.Error("short write")
 			}
 			}
 		}
 		}
 		w.Close()
 		w.Close()

+ 1 - 1
daemon/logger/factory.go

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

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

@@ -14,7 +14,7 @@ import (
 	"github.com/docker/docker/daemon/logger"
 	"github.com/docker/docker/daemon/logger"
 	"github.com/docker/docker/daemon/logger/loggerutils"
 	"github.com/docker/docker/daemon/logger/loggerutils"
 	"github.com/docker/docker/pkg/urlutil"
 	"github.com/docker/docker/pkg/urlutil"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 	"github.com/fluent/fluent-logger-golang/fluent"
 	"github.com/fluent/fluent-logger-golang/fluent"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"

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

@@ -18,7 +18,7 @@ import (
 const name = "journald"
 const name = "journald"
 
 
 type journald struct {
 type journald struct {
-	mu      sync.Mutex
+	mu      sync.Mutex        //nolint:structcheck,unused
 	vars    map[string]string // additional variables and values to send to the journal along with the log message
 	vars    map[string]string // additional variables and values to send to the journal along with the log message
 	readers map[*logger.LogWatcher]struct{}
 	readers map[*logger.LogWatcher]struct{}
 }
 }

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

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

+ 4 - 4
daemon/logger/jsonfilelog/jsonfilelog_test.go

@@ -188,15 +188,15 @@ func TestJSONFileLoggerWithOpts(t *testing.T) {
 		}
 		}
 
 
 		file, err := os.Open(filename + ".1.gz")
 		file, err := os.Open(filename + ".1.gz")
-		defer file.Close()
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
+		defer file.Close()
 		zipReader, err := gzip.NewReader(file)
 		zipReader, err := gzip.NewReader(file)
-		defer zipReader.Close()
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
+		defer zipReader.Close()
 		penUlt, err = ioutil.ReadAll(zipReader)
 		penUlt, err = ioutil.ReadAll(zipReader)
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
@@ -204,15 +204,15 @@ func TestJSONFileLoggerWithOpts(t *testing.T) {
 	}
 	}
 
 
 	file, err := os.Open(filename + ".2.gz")
 	file, err := os.Open(filename + ".2.gz")
-	defer file.Close()
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
+	defer file.Close()
 	zipReader, err := gzip.NewReader(file)
 	zipReader, err := gzip.NewReader(file)
-	defer zipReader.Close()
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
+	defer zipReader.Close()
 	antepenult, err := ioutil.ReadAll(zipReader)
 	antepenult, err := ioutil.ReadAll(zipReader)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)

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

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

+ 1 - 1
daemon/logger/metrics.go

@@ -1,7 +1,7 @@
 package logger // import "github.com/docker/docker/daemon/logger"
 package logger // import "github.com/docker/docker/daemon/logger"
 
 
 import (
 import (
-	"github.com/docker/go-metrics"
+	metrics "github.com/docker/go-metrics"
 )
 )
 
 
 var (
 var (

+ 1 - 1
daemon/metrics.go

@@ -6,7 +6,7 @@ import (
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/pkg/plugins"
 	"github.com/docker/docker/pkg/plugins"
-	"github.com/docker/go-metrics"
+	metrics "github.com/docker/go-metrics"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/sirupsen/logrus"
 	"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/plugingetter"
 	"github.com/docker/docker/pkg/plugins"
 	"github.com/docker/docker/pkg/plugins"
 	"github.com/docker/docker/plugin"
 	"github.com/docker/docker/plugin"
-	"github.com/docker/go-metrics"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	metrics "github.com/docker/go-metrics"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sys/unix"
 	"golang.org/x/sys/unix"

+ 3 - 5
daemon/monitor.go

@@ -202,15 +202,13 @@ func (daemon *Daemon) autoRemove(c *container.Container) {
 		return
 		return
 	}
 	}
 
 
-	var err error
-	if err = daemon.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true, RemoveVolume: true}); err == nil {
+	err := daemon.ContainerRm(c.ID, &types.ContainerRmConfig{ForceRemove: true, RemoveVolume: true})
+	if err == nil {
 		return
 		return
 	}
 	}
 	if c := daemon.containers.Get(c.ID); c == nil {
 	if c := daemon.containers.Get(c.ID); c == nil {
 		return
 		return
 	}
 	}
 
 
-	if err != nil {
-		logrus.WithError(err).WithField("container", c.ID).Error("error removing container")
-	}
+	logrus.WithError(err).WithField("container", c.ID).Error("error removing container")
 }
 }

+ 0 - 6
daemon/network.go

@@ -960,12 +960,6 @@ func buildCreateEndpointOptions(c *container.Container, n libnetwork.Network, ep
 	return createOptions, nil
 	return createOptions, nil
 }
 }
 
 
-// getEndpointInNetwork returns the container's endpoint to the provided network.
-func getEndpointInNetwork(name string, n libnetwork.Network) (libnetwork.Endpoint, error) {
-	endpointName := strings.TrimPrefix(name, "/")
-	return n.EndpointByName(endpointName)
-}
-
 // getSandboxPortMapInfo retrieves the current port-mapping programmed for the given sandbox
 // getSandboxPortMapInfo retrieves the current port-mapping programmed for the given sandbox
 func getSandboxPortMapInfo(sb libnetwork.Sandbox) nat.PortMap {
 func getSandboxPortMapInfo(sb libnetwork.Sandbox) nat.PortMap {
 	pm := nat.PortMap{}
 	pm := nat.PortMap{}

+ 13 - 0
daemon/network_windows.go

@@ -0,0 +1,13 @@
+package daemon
+
+import (
+	"strings"
+
+	"github.com/docker/libnetwork"
+)
+
+// getEndpointInNetwork returns the container's endpoint to the provided network.
+func getEndpointInNetwork(name string, n libnetwork.Network) (libnetwork.Endpoint, error) {
+	endpointName := strings.TrimPrefix(name, "/")
+	return n.EndpointByName(endpointName)
+}

+ 1 - 1
daemon/nvidia_linux.go

@@ -8,7 +8,7 @@ import (
 
 
 	"github.com/containerd/containerd/contrib/nvidia"
 	"github.com/containerd/containerd/contrib/nvidia"
 	"github.com/docker/docker/pkg/capabilities"
 	"github.com/docker/docker/pkg/capabilities"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 )
 )
 
 

+ 1 - 1
daemon/oci_linux.go

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

+ 1 - 1
daemon/oci_utils.go

@@ -2,7 +2,7 @@ package daemon // import "github.com/docker/docker/daemon"
 
 
 import (
 import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 )
 )
 
 
 func setLinuxDomainname(c *container.Container, s *specs.Spec) {
 func setLinuxDomainname(c *container.Container, s *specs.Spec) {

+ 1 - 1
daemon/oci_windows.go

@@ -15,7 +15,7 @@ import (
 	"github.com/docker/docker/oci/caps"
 	"github.com/docker/docker/oci/caps"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/sys/windows/registry"
 	"golang.org/x/sys/windows/registry"

+ 1 - 1
daemon/oci_windows_test.go

@@ -14,7 +14,7 @@ import (
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	swarmagent "github.com/docker/swarmkit/agent"
 	swarmagent "github.com/docker/swarmkit/agent"
 	swarmapi "github.com/docker/swarmkit/api"
 	swarmapi "github.com/docker/swarmkit/api"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 	"golang.org/x/sys/windows/registry"
 	"golang.org/x/sys/windows/registry"
 	"gotest.tools/assert"
 	"gotest.tools/assert"
 )
 )

+ 3 - 3
daemon/seccomp_linux.go

@@ -10,7 +10,7 @@ import (
 	coci "github.com/containerd/containerd/oci"
 	coci "github.com/containerd/containerd/oci"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/container"
 	"github.com/docker/docker/profiles/seccomp"
 	"github.com/docker/docker/profiles/seccomp"
-	"github.com/opencontainers/runtime-spec/specs-go"
+	specs "github.com/opencontainers/runtime-spec/specs-go"
 	"github.com/sirupsen/logrus"
 	"github.com/sirupsen/logrus"
 )
 )
 
 
@@ -28,9 +28,9 @@ func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
 
 
 		if !daemon.seccompEnabled {
 		if !daemon.seccompEnabled {
 			if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
 			if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
-				return fmt.Errorf("Seccomp is not enabled in your kernel, cannot run a custom seccomp profile.")
+				return fmt.Errorf("seccomp is not enabled in your kernel, cannot run a custom seccomp profile")
 			}
 			}
-			logrus.Warn("Seccomp is not enabled in your kernel, running container without default profile.")
+			logrus.Warn("seccomp is not enabled in your kernel, running container without default profile")
 			c.SeccompProfile = "unconfined"
 			c.SeccompProfile = "unconfined"
 		}
 		}
 		if c.SeccompProfile == "unconfined" {
 		if c.SeccompProfile == "unconfined" {

+ 1 - 1
daemon/selinux_linux.go

@@ -1,6 +1,6 @@
 package daemon // import "github.com/docker/docker/daemon"
 package daemon // import "github.com/docker/docker/daemon"
 
 
-import "github.com/opencontainers/selinux/go-selinux"
+import selinux "github.com/opencontainers/selinux/go-selinux"
 
 
 func selinuxSetDisabled() {
 func selinuxSetDisabled() {
 	selinux.SetDisabled()
 	selinux.SetDisabled()

+ 1 - 1
daemon/top_windows.go

@@ -7,7 +7,7 @@ import (
 	"time"
 	"time"
 
 
 	containertypes "github.com/docker/docker/api/types/container"
 	containertypes "github.com/docker/docker/api/types/container"
-	"github.com/docker/go-units"
+	units "github.com/docker/go-units"
 )
 )
 
 
 // ContainerTop handles `docker top` client requests.
 // ContainerTop handles `docker top` client requests.

+ 1 - 1
daemon/update_linux.go

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

+ 1 - 1
distribution/config.go

@@ -19,7 +19,7 @@ import (
 	refstore "github.com/docker/docker/reference"
 	refstore "github.com/docker/docker/reference"
 	"github.com/docker/docker/registry"
 	"github.com/docker/docker/registry"
 	"github.com/docker/libtrust"
 	"github.com/docker/libtrust"
-	"github.com/opencontainers/go-digest"
+	digest "github.com/opencontainers/go-digest"
 	specs "github.com/opencontainers/image-spec/specs-go/v1"
 	specs "github.com/opencontainers/image-spec/specs-go/v1"
 )
 )
 
 

+ 1 - 1
distribution/errors.go

@@ -9,7 +9,7 @@ import (
 	"github.com/docker/distribution"
 	"github.com/docker/distribution"
 	"github.com/docker/distribution/reference"
 	"github.com/docker/distribution/reference"
 	"github.com/docker/distribution/registry/api/errcode"
 	"github.com/docker/distribution/registry/api/errcode"
-	"github.com/docker/distribution/registry/api/v2"
+	v2 "github.com/docker/distribution/registry/api/v2"
 	"github.com/docker/distribution/registry/client"
 	"github.com/docker/distribution/registry/client"
 	"github.com/docker/distribution/registry/client/auth"
 	"github.com/docker/distribution/registry/client/auth"
 	"github.com/docker/docker/distribution/xfer"
 	"github.com/docker/docker/distribution/xfer"

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