Skip to content

Commit

Permalink
Various code-cleanup
Browse files Browse the repository at this point in the history
remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed May 23, 2018
1 parent 0846a02 commit f23c00d
Show file tree
Hide file tree
Showing 112 changed files with 168 additions and 182 deletions.
4 changes: 2 additions & 2 deletions api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 1 addition & 1 deletion api/common_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion api/server/router/build/build_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
3 changes: 1 addition & 2 deletions api/server/server_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion api/types/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion builder/dockerfile/buildargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion builder/dockerfile/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion builder/dockerfile/instructions/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package instructions // import "github.com/docker/docker/builder/dockerfile/inst

import (
"errors"

"strings"

"github.com/docker/docker/api/types/container"
Expand Down
2 changes: 1 addition & 1 deletion builder/dockerfile/instructions/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type testCase struct {
}

func initTestCases() []testCase {
testCases := []testCase{}
var testCases []testCase

testCases = append(testCases, testCase{
name: "empty args",
Expand Down
3 changes: 1 addition & 2 deletions builder/dockerfile/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion builder/dockerfile/shell/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion builder/remotecontext/tarsum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions cli/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions client/container_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client // import "github.com/docker/docker/client"

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
Expand All @@ -11,8 +12,6 @@ import (
"testing"
"time"

"context"

"github.com/docker/docker/api/types/container"
)

Expand Down
1 change: 0 additions & 1 deletion client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package client // import "github.com/docker/docker/client"

import (
"fmt"

"net/http"

"github.com/docker/docker/api/types/versions"
Expand Down
3 changes: 1 addition & 2 deletions client/image_save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"io/ioutil"
"net/http"
"reflect"
"testing"

"strings"
"testing"
)

func TestImageSaveError(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions client/node_remove.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package client // import "github.com/docker/docker/client"

import (
"net/url"

"context"
"net/url"

"github.com/docker/docker/api/types"
)
Expand Down
3 changes: 1 addition & 2 deletions client/node_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
3 changes: 1 addition & 2 deletions client/plugin_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion client/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),

Expand Down
2 changes: 1 addition & 1 deletion client/service_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dockerd/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/dockerd/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net"
"net/http"

metrics "github.com/docker/go-metrics"
"github.com/docker/go-metrics"
"github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion container/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion daemon/cluster/convert/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion daemon/cluster/executor/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion daemon/config/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion daemon/config/config_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions daemon/daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion daemon/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions daemon/graphdriver/aufs/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions daemon/graphdriver/devmapper/deviceset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/devmapper/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/graphtest/graphtest_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion daemon/graphdriver/graphtest/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit f23c00d

Please sign in to comment.