Browse code

Fix go vet errors

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

LK4D4 authored on 2014/06/12 14:15:53
Showing 12 changed files
... ...
@@ -91,7 +91,7 @@ func (cli *DockerCli) CmdHelp(args ...string) error {
91 91
 
92 92
 // FIXME: 'insert' is deprecated.
93 93
 func (cli *DockerCli) CmdInsert(args ...string) error {
94
-	fmt.Fprintf(os.Stderr, "Warning: '%s' is deprecated and will be removed in a future version. Please use 'docker build' and 'ADD' instead.\n")
94
+	fmt.Fprintf(os.Stderr, "Warning: 'insert' is deprecated and will be removed in a future version. Please use 'docker build' and 'ADD' instead.\n")
95 95
 	cmd := cli.Subcmd("insert", "IMAGE URL PATH", "Insert a file from URL in the IMAGE at PATH")
96 96
 	if err := cmd.Parse(args); err != nil {
97 97
 		return nil
... ...
@@ -164,6 +164,6 @@ func TestUntarUstarGnuConflict(t *testing.T) {
164 164
 		}
165 165
 	}
166 166
 	if !found {
167
-		t.Fatal("%s not found in the archive", "root/.cpanm/work/1395823785.24209/Plack-1.0030/blib/man3/Plack::Middleware::LighttpdScriptNameFix.3pm")
167
+		t.Fatalf("%s not found in the archive", "root/.cpanm/work/1395823785.24209/Plack-1.0030/blib/man3/Plack::Middleware::LighttpdScriptNameFix.3pm")
168 168
 	}
169 169
 }
... ...
@@ -55,7 +55,7 @@ type DevInfo struct {
55 55
 }
56 56
 
57 57
 type MetaData struct {
58
-	Devices     map[string]*DevInfo `json:devices`
58
+	Devices     map[string]*DevInfo `json:"Devices"`
59 59
 	devicesLock sync.Mutex          `json:"-"` // Protects all read/writes to Devices map
60 60
 }
61 61
 
... ...
@@ -1,12 +1,13 @@
1 1
 package graphtest
2 2
 
3 3
 import (
4
-	"github.com/dotcloud/docker/daemon/graphdriver"
5 4
 	"io/ioutil"
6 5
 	"os"
7 6
 	"path"
8 7
 	"syscall"
9 8
 	"testing"
9
+
10
+	"github.com/dotcloud/docker/daemon/graphdriver"
10 11
 )
11 12
 
12 13
 var (
... ...
@@ -94,10 +95,10 @@ func verifyFile(t *testing.T, path string, mode os.FileMode, uid, gid uint32) {
94 94
 
95 95
 	if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
96 96
 		if stat.Uid != uid {
97
-			t.Fatal("%s no owned by uid %d", path, uid)
97
+			t.Fatalf("%s no owned by uid %d", path, uid)
98 98
 		}
99 99
 		if stat.Gid != gid {
100
-			t.Fatal("%s not owned by gid %d", path, gid)
100
+			t.Fatalf("%s not owned by gid %d", path, gid)
101 101
 		}
102 102
 	}
103 103
 
... ...
@@ -141,7 +141,7 @@ func TestOutputAdd(t *testing.T) {
141 141
 		t.Fatalf("Expected %d, got %d", len(input), n)
142 142
 	}
143 143
 	if output := b.String(); output != input {
144
-		t.Fatal("Received wrong data from Add.\nExpected: '%s'\nGot:     '%s'", input, output)
144
+		t.Fatalf("Received wrong data from Add.\nExpected: '%s'\nGot:     '%s'", input, output)
145 145
 	}
146 146
 }
147 147
 
... ...
@@ -137,5 +137,4 @@ func (t *Table) ReadFrom(src io.Reader) (n int64, err error) {
137 137
 		}
138 138
 		t.Add(env)
139 139
 	}
140
-	return 0, nil
141 140
 }
... ...
@@ -27,14 +27,14 @@ func TestCLIImageTagRemove(t *testing.T) {
27 27
 	{
28 28
 		imagesAfter, _, _ := cmd(t, "images", "-a")
29 29
 		if nLines(imagesAfter) != nLines(imagesBefore)+3 {
30
-			t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
30
+			t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
31 31
 		}
32 32
 	}
33 33
 	cmd(t, "rmi", "utest/docker:tag2")
34 34
 	{
35 35
 		imagesAfter, _, _ := cmd(t, "images", "-a")
36 36
 		if nLines(imagesAfter) != nLines(imagesBefore)+2 {
37
-			t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
37
+			t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
38 38
 		}
39 39
 
40 40
 	}
... ...
@@ -42,7 +42,7 @@ func TestCLIImageTagRemove(t *testing.T) {
42 42
 	{
43 43
 		imagesAfter, _, _ := cmd(t, "images", "-a")
44 44
 		if nLines(imagesAfter) != nLines(imagesBefore)+1 {
45
-			t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
45
+			t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
46 46
 		}
47 47
 
48 48
 	}
... ...
@@ -50,7 +50,7 @@ func TestCLIImageTagRemove(t *testing.T) {
50 50
 	{
51 51
 		imagesAfter, _, _ := cmd(t, "images", "-a")
52 52
 		if nLines(imagesAfter) != nLines(imagesBefore)+0 {
53
-			t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
53
+			t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
54 54
 		}
55 55
 
56 56
 	}
... ...
@@ -450,32 +450,32 @@ func TestVolumeWithSymlink(t *testing.T) {
450 450
 	buildCmd.Dir = buildDirectory
451 451
 	err := buildCmd.Run()
452 452
 	if err != nil {
453
-		t.Fatal("could not build 'docker-test-volumewithsymlink': %v", err)
453
+		t.Fatalf("could not build 'docker-test-volumewithsymlink': %v", err)
454 454
 	}
455 455
 
456 456
 	cmd := exec.Command(dockerBinary, "run", "-v", "/bar/foo", "--name", "test-volumewithsymlink", "docker-test-volumewithsymlink", "sh", "-c", "mount | grep -q /foo/foo")
457 457
 	exitCode, err := runCommand(cmd)
458 458
 	if err != nil || exitCode != 0 {
459
-		t.Fatal("[run] err: %v, exitcode: %d", err, exitCode)
459
+		t.Fatalf("[run] err: %v, exitcode: %d", err, exitCode)
460 460
 	}
461 461
 
462 462
 	var volPath string
463 463
 	cmd = exec.Command(dockerBinary, "inspect", "-f", "{{range .Volumes}}{{.}}{{end}}", "test-volumewithsymlink")
464 464
 	volPath, exitCode, err = runCommandWithOutput(cmd)
465 465
 	if err != nil || exitCode != 0 {
466
-		t.Fatal("[inspect] err: %v, exitcode: %d", err, exitCode)
466
+		t.Fatalf("[inspect] err: %v, exitcode: %d", err, exitCode)
467 467
 	}
468 468
 
469 469
 	cmd = exec.Command(dockerBinary, "rm", "-v", "test-volumewithsymlink")
470 470
 	exitCode, err = runCommand(cmd)
471 471
 	if err != nil || exitCode != 0 {
472
-		t.Fatal("[rm] err: %v, exitcode: %d", err, exitCode)
472
+		t.Fatalf("[rm] err: %v, exitcode: %d", err, exitCode)
473 473
 	}
474 474
 
475 475
 	f, err := os.Open(volPath)
476 476
 	defer f.Close()
477 477
 	if !os.IsNotExist(err) {
478
-		t.Fatal("[open] (expecting 'file does not exist' error) err: %v, volPath: %s", err, volPath)
478
+		t.Fatalf("[open] (expecting 'file does not exist' error) err: %v, volPath: %s", err, volPath)
479 479
 	}
480 480
 
481 481
 	deleteImages("docker-test-volumewithsymlink")
... ...
@@ -1,13 +1,14 @@
1 1
 package graphdb
2 2
 
3 3
 import (
4
-	_ "code.google.com/p/gosqlite/sqlite3"
5 4
 	"database/sql"
6 5
 	"fmt"
7 6
 	"os"
8 7
 	"path"
9 8
 	"strconv"
10 9
 	"testing"
10
+
11
+	_ "code.google.com/p/gosqlite/sqlite3"
11 12
 )
12 13
 
13 14
 func newTestDb(t *testing.T) (*Database, string) {
... ...
@@ -535,6 +536,6 @@ func TestConcurrentWrites(t *testing.T) {
535 535
 		}
536 536
 	}
537 537
 	if any {
538
-		t.Fatal()
538
+		t.Fail()
539 539
 	}
540 540
 }
... ...
@@ -28,8 +28,8 @@ func main() {
28 28
 		flag.PrintDefaults()
29 29
 	} else {
30 30
 		fmt.Printf("s/#hidden/-string: %s\n", str)
31
-		fmt.Printf("b: %b\n", b)
32
-		fmt.Printf("-bool: %b\n", b2)
31
+		fmt.Printf("b: %t\n", b)
32
+		fmt.Printf("-bool: %t\n", b2)
33 33
 		fmt.Printf("s/#hidden/-string(via lookup): %s\n", flag.Lookup("s").Value.String())
34 34
 		fmt.Printf("ARGS: %v\n", flag.Args())
35 35
 	}
... ...
@@ -264,7 +264,7 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) {
264 264
 		AddRequiredHeadersToRedirectedRequests(reqTo, []*http.Request{reqFrom})
265 265
 
266 266
 		if len(reqTo.Header) != 1 {
267
-			t.Fatal("Expected 1 headers, got %d", len(reqTo.Header))
267
+			t.Fatalf("Expected 1 headers, got %d", len(reqTo.Header))
268 268
 		}
269 269
 
270 270
 		if reqTo.Header.Get("Content-Type") != "application/json" {
... ...
@@ -288,7 +288,7 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) {
288 288
 		AddRequiredHeadersToRedirectedRequests(reqTo, []*http.Request{reqFrom})
289 289
 
290 290
 		if len(reqTo.Header) != 2 {
291
-			t.Fatal("Expected 2 headers, got %d", len(reqTo.Header))
291
+			t.Fatalf("Expected 2 headers, got %d", len(reqTo.Header))
292 292
 		}
293 293
 
294 294
 		if reqTo.Header.Get("Content-Type") != "application/json" {
... ...
@@ -4,11 +4,12 @@ import (
4 4
 	"bytes"
5 5
 	"crypto/rand"
6 6
 	"fmt"
7
-	"github.com/dotcloud/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
8 7
 	"io"
9 8
 	"io/ioutil"
10 9
 	"os"
11 10
 	"testing"
11
+
12
+	"github.com/dotcloud/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
12 13
 )
13 14
 
14 15
 type testLayer struct {
... ...
@@ -109,7 +110,7 @@ func TestTarSums(t *testing.T) {
109 109
 			fh = sizedTar(*layer.options)
110 110
 		} else {
111 111
 			// What else is there to test?
112
-			t.Errorf("what to do with %#V", layer)
112
+			t.Errorf("what to do with %#v", layer)
113 113
 			continue
114 114
 		}
115 115
 		if file, ok := fh.(*os.File); ok {