mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1032 from andrewsmedina/govet
following the 'go vet' suggestions for the docker package.
This commit is contained in:
commit
a11fc9f067
4 changed files with 14 additions and 14 deletions
14
api_test.go
14
api_test.go
|
@ -19,25 +19,25 @@ import (
|
|||
|
||||
func TestGetBoolParam(t *testing.T) {
|
||||
if ret, err := getBoolParam("true"); err != nil || !ret {
|
||||
t.Fatalf("true -> true, nil | got %b %s", ret, err)
|
||||
t.Fatalf("true -> true, nil | got %t %s", ret, err)
|
||||
}
|
||||
if ret, err := getBoolParam("True"); err != nil || !ret {
|
||||
t.Fatalf("True -> true, nil | got %b %s", ret, err)
|
||||
t.Fatalf("True -> true, nil | got %t %s", ret, err)
|
||||
}
|
||||
if ret, err := getBoolParam("1"); err != nil || !ret {
|
||||
t.Fatalf("1 -> true, nil | got %b %s", ret, err)
|
||||
t.Fatalf("1 -> true, nil | got %t %s", ret, err)
|
||||
}
|
||||
if ret, err := getBoolParam(""); err != nil || ret {
|
||||
t.Fatalf("\"\" -> false, nil | got %b %s", ret, err)
|
||||
t.Fatalf("\"\" -> false, nil | got %t %s", ret, err)
|
||||
}
|
||||
if ret, err := getBoolParam("false"); err != nil || ret {
|
||||
t.Fatalf("false -> false, nil | got %b %s", ret, err)
|
||||
t.Fatalf("false -> false, nil | got %t %s", ret, err)
|
||||
}
|
||||
if ret, err := getBoolParam("0"); err != nil || ret {
|
||||
t.Fatalf("0 -> false, nil | got %b %s", ret, err)
|
||||
t.Fatalf("0 -> false, nil | got %t %s", ret, err)
|
||||
}
|
||||
if ret, err := getBoolParam("faux"); err == nil || ret {
|
||||
t.Fatalf("faux -> false, err | got %b %s", ret, err)
|
||||
t.Fatalf("faux -> false, err | got %t %s", ret, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
|
|||
}
|
||||
auth.SaveConfig(cli.authConfig)
|
||||
if out2.Status != "" {
|
||||
fmt.Fprintln(cli.out, "%s\n", out2.Status)
|
||||
fmt.Fprintf(cli.out, "%s\n", out2.Status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ func (cli *DockerCli) CmdWait(args ...string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(cli.out, "%s\n", out.StatusCode)
|
||||
fmt.Fprintf(cli.out, "%d\n", out.StatusCode)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -405,7 +405,7 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
|||
fmt.Fprintf(cli.out, "Git commit: %s\n", out.GitCommit)
|
||||
}
|
||||
if out.GoVersion != "" {
|
||||
fmt.Fprintln(cli.out, "Go version: %s\n", out.GoVersion)
|
||||
fmt.Fprintf(cli.out, "Go version: %s\n", out.GoVersion)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
|
|||
if err != nil {
|
||||
fmt.Fprintf(cli.err, "%s\n", err)
|
||||
} else {
|
||||
fmt.Fprintln(cli.out, "%s\n", name)
|
||||
fmt.Fprintf(cli.out, "%s\n", name)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
2
graph.go
2
graph.go
|
@ -189,7 +189,7 @@ func (graph *Graph) Mktemp(id string) (string, error) {
|
|||
return "", fmt.Errorf("Couldn't create temp: %s", err)
|
||||
}
|
||||
if tmp.Exists(id) {
|
||||
return "", fmt.Errorf("Image %d already exists", id)
|
||||
return "", fmt.Errorf("Image %s already exists", id)
|
||||
}
|
||||
return tmp.imageRoot(id), nil
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ func (r *progressReader) Read(p []byte) (n int, err error) {
|
|||
}
|
||||
if r.readProgress-r.lastUpdate > updateEvery || err != nil {
|
||||
if r.readTotal > 0 {
|
||||
fmt.Fprintf(r.output, r.template, HumanSize(int64(r.readProgress)), HumanSize(int64(r.readTotal)), fmt.Sprintf("%2.0f%%",float64(r.readProgress)/float64(r.readTotal)*100))
|
||||
fmt.Fprintf(r.output, r.template, HumanSize(int64(r.readProgress)), HumanSize(int64(r.readTotal)), fmt.Sprintf("%2.0f%%", float64(r.readProgress)/float64(r.readTotal)*100))
|
||||
} else {
|
||||
fmt.Fprintf(r.output, r.template, r.readProgress, "?", "n/a")
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ func HumanDuration(d time.Duration) string {
|
|||
} else if hours < 24*365*2 {
|
||||
return fmt.Sprintf("%d months", hours/24/30)
|
||||
}
|
||||
return fmt.Sprintf("%d years", d.Hours()/24/365)
|
||||
return fmt.Sprintf("%f years", d.Hours()/24/365)
|
||||
}
|
||||
|
||||
// HumanSize returns a human-readable approximation of a size
|
||||
|
|
Loading…
Reference in a new issue