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)
This commit is contained in:
LK4D4 2014-06-12 09:15:53 +04:00 committed by Victor Vieux
parent f0ec901819
commit f08cd445b0
12 changed files with 27 additions and 25 deletions

View file

@ -91,7 +91,7 @@ func (cli *DockerCli) CmdHelp(args ...string) error {
// FIXME: 'insert' is deprecated.
func (cli *DockerCli) CmdInsert(args ...string) error {
fmt.Fprintf(os.Stderr, "Warning: '%s' is deprecated and will be removed in a future version. Please use 'docker build' and 'ADD' instead.\n")
fmt.Fprintf(os.Stderr, "Warning: 'insert' is deprecated and will be removed in a future version. Please use 'docker build' and 'ADD' instead.\n")
cmd := cli.Subcmd("insert", "IMAGE URL PATH", "Insert a file from URL in the IMAGE at PATH")
if err := cmd.Parse(args); err != nil {
return nil

View file

@ -164,6 +164,6 @@ func TestUntarUstarGnuConflict(t *testing.T) {
}
}
if !found {
t.Fatal("%s not found in the archive", "root/.cpanm/work/1395823785.24209/Plack-1.0030/blib/man3/Plack::Middleware::LighttpdScriptNameFix.3pm")
t.Fatalf("%s not found in the archive", "root/.cpanm/work/1395823785.24209/Plack-1.0030/blib/man3/Plack::Middleware::LighttpdScriptNameFix.3pm")
}
}

View file

@ -55,7 +55,7 @@ type DevInfo struct {
}
type MetaData struct {
Devices map[string]*DevInfo `json:devices`
Devices map[string]*DevInfo `json:"Devices"`
devicesLock sync.Mutex `json:"-"` // Protects all read/writes to Devices map
}

View file

@ -1,12 +1,13 @@
package graphtest
import (
"github.com/dotcloud/docker/daemon/graphdriver"
"io/ioutil"
"os"
"path"
"syscall"
"testing"
"github.com/dotcloud/docker/daemon/graphdriver"
)
var (
@ -94,10 +95,10 @@ func verifyFile(t *testing.T, path string, mode os.FileMode, uid, gid uint32) {
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
if stat.Uid != uid {
t.Fatal("%s no owned by uid %d", path, uid)
t.Fatalf("%s no owned by uid %d", path, uid)
}
if stat.Gid != gid {
t.Fatal("%s not owned by gid %d", path, gid)
t.Fatalf("%s not owned by gid %d", path, gid)
}
}

View file

@ -141,7 +141,7 @@ func TestOutputAdd(t *testing.T) {
t.Fatalf("Expected %d, got %d", len(input), n)
}
if output := b.String(); output != input {
t.Fatal("Received wrong data from Add.\nExpected: '%s'\nGot: '%s'", input, output)
t.Fatalf("Received wrong data from Add.\nExpected: '%s'\nGot: '%s'", input, output)
}
}

View file

@ -137,5 +137,4 @@ func (t *Table) ReadFrom(src io.Reader) (n int64, err error) {
}
t.Add(env)
}
return 0, nil
}

View file

@ -27,14 +27,14 @@ func TestCLIImageTagRemove(t *testing.T) {
{
imagesAfter, _, _ := cmd(t, "images", "-a")
if nLines(imagesAfter) != nLines(imagesBefore)+3 {
t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
}
}
cmd(t, "rmi", "utest/docker:tag2")
{
imagesAfter, _, _ := cmd(t, "images", "-a")
if nLines(imagesAfter) != nLines(imagesBefore)+2 {
t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
}
}
@ -42,7 +42,7 @@ func TestCLIImageTagRemove(t *testing.T) {
{
imagesAfter, _, _ := cmd(t, "images", "-a")
if nLines(imagesAfter) != nLines(imagesBefore)+1 {
t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
}
}
@ -50,7 +50,7 @@ func TestCLIImageTagRemove(t *testing.T) {
{
imagesAfter, _, _ := cmd(t, "images", "-a")
if nLines(imagesAfter) != nLines(imagesBefore)+0 {
t.Fatalf("before: %#s\n\nafter: %#s\n", imagesBefore, imagesAfter)
t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter)
}
}

View file

@ -450,32 +450,32 @@ func TestVolumeWithSymlink(t *testing.T) {
buildCmd.Dir = buildDirectory
err := buildCmd.Run()
if err != nil {
t.Fatal("could not build 'docker-test-volumewithsymlink': %v", err)
t.Fatalf("could not build 'docker-test-volumewithsymlink': %v", err)
}
cmd := exec.Command(dockerBinary, "run", "-v", "/bar/foo", "--name", "test-volumewithsymlink", "docker-test-volumewithsymlink", "sh", "-c", "mount | grep -q /foo/foo")
exitCode, err := runCommand(cmd)
if err != nil || exitCode != 0 {
t.Fatal("[run] err: %v, exitcode: %d", err, exitCode)
t.Fatalf("[run] err: %v, exitcode: %d", err, exitCode)
}
var volPath string
cmd = exec.Command(dockerBinary, "inspect", "-f", "{{range .Volumes}}{{.}}{{end}}", "test-volumewithsymlink")
volPath, exitCode, err = runCommandWithOutput(cmd)
if err != nil || exitCode != 0 {
t.Fatal("[inspect] err: %v, exitcode: %d", err, exitCode)
t.Fatalf("[inspect] err: %v, exitcode: %d", err, exitCode)
}
cmd = exec.Command(dockerBinary, "rm", "-v", "test-volumewithsymlink")
exitCode, err = runCommand(cmd)
if err != nil || exitCode != 0 {
t.Fatal("[rm] err: %v, exitcode: %d", err, exitCode)
t.Fatalf("[rm] err: %v, exitcode: %d", err, exitCode)
}
f, err := os.Open(volPath)
defer f.Close()
if !os.IsNotExist(err) {
t.Fatal("[open] (expecting 'file does not exist' error) err: %v, volPath: %s", err, volPath)
t.Fatalf("[open] (expecting 'file does not exist' error) err: %v, volPath: %s", err, volPath)
}
deleteImages("docker-test-volumewithsymlink")

View file

@ -1,13 +1,14 @@
package graphdb
import (
_ "code.google.com/p/gosqlite/sqlite3"
"database/sql"
"fmt"
"os"
"path"
"strconv"
"testing"
_ "code.google.com/p/gosqlite/sqlite3"
)
func newTestDb(t *testing.T) (*Database, string) {
@ -535,6 +536,6 @@ func TestConcurrentWrites(t *testing.T) {
}
}
if any {
t.Fatal()
t.Fail()
}
}

View file

@ -28,8 +28,8 @@ func main() {
flag.PrintDefaults()
} else {
fmt.Printf("s/#hidden/-string: %s\n", str)
fmt.Printf("b: %b\n", b)
fmt.Printf("-bool: %b\n", b2)
fmt.Printf("b: %t\n", b)
fmt.Printf("-bool: %t\n", b2)
fmt.Printf("s/#hidden/-string(via lookup): %s\n", flag.Lookup("s").Value.String())
fmt.Printf("ARGS: %v\n", flag.Args())
}

View file

@ -264,7 +264,7 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) {
AddRequiredHeadersToRedirectedRequests(reqTo, []*http.Request{reqFrom})
if len(reqTo.Header) != 1 {
t.Fatal("Expected 1 headers, got %d", len(reqTo.Header))
t.Fatalf("Expected 1 headers, got %d", len(reqTo.Header))
}
if reqTo.Header.Get("Content-Type") != "application/json" {
@ -288,7 +288,7 @@ func TestAddRequiredHeadersToRedirectedRequests(t *testing.T) {
AddRequiredHeadersToRedirectedRequests(reqTo, []*http.Request{reqFrom})
if len(reqTo.Header) != 2 {
t.Fatal("Expected 2 headers, got %d", len(reqTo.Header))
t.Fatalf("Expected 2 headers, got %d", len(reqTo.Header))
}
if reqTo.Header.Get("Content-Type") != "application/json" {

View file

@ -4,11 +4,12 @@ import (
"bytes"
"crypto/rand"
"fmt"
"github.com/dotcloud/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
"io"
"io/ioutil"
"os"
"testing"
"github.com/dotcloud/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
)
type testLayer struct {
@ -109,7 +110,7 @@ func TestTarSums(t *testing.T) {
fh = sizedTar(*layer.options)
} else {
// What else is there to test?
t.Errorf("what to do with %#V", layer)
t.Errorf("what to do with %#v", layer)
continue
}
if file, ok := fh.(*os.File); ok {