From 08405824ad6da73fa08dbcbf41e2de0e5c236f48 Mon Sep 17 00:00:00 2001 From: fate-grand-order Date: Tue, 21 Feb 2017 20:20:18 +0800 Subject: [PATCH] Use errors.New() directly to output the error message Signed-off-by: fate-grand-order --- cmd/ctr/run.go | 4 ++-- cmd/dist/ingest.go | 4 ++-- cmd/dist/list.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/ctr/run.go b/cmd/ctr/run.go index 9823722..bc0db65 100644 --- a/cmd/ctr/run.go +++ b/cmd/ctr/run.go @@ -2,7 +2,6 @@ package main import ( "encoding/json" - "fmt" "io/ioutil" "path/filepath" @@ -17,6 +16,7 @@ import ( protobuf "github.com/gogo/protobuf/types" "github.com/opencontainers/runtime-spec/specs-go" "github.com/urfave/cli" + "github.com/pkg/errors" ) var rwm = "rwm" @@ -175,7 +175,7 @@ var runCommand = cli.Command{ Action: func(context *cli.Context) error { id := context.String("id") if id == "" { - return fmt.Errorf("container id must be provided") + return errors.New("container id must be provided") } containers, err := getExecutionService(context) diff --git a/cmd/dist/ingest.go b/cmd/dist/ingest.go index 8d8a7cc..8d7b4c8 100644 --- a/cmd/dist/ingest.go +++ b/cmd/dist/ingest.go @@ -2,13 +2,13 @@ package main import ( contextpkg "context" - "fmt" "os" contentapi "github.com/docker/containerd/api/services/content" "github.com/docker/containerd/content" "github.com/opencontainers/go-digest" "github.com/urfave/cli" + "github.com/pkg/errors" ) var ingestCommand = cli.Command{ @@ -48,7 +48,7 @@ var ingestCommand = cli.Command{ } if ref == "" { - return fmt.Errorf("must specify a transaction reference") + return errors.New("must specify a transaction reference") } ingester := content.NewIngesterFromClient(contentapi.NewContentClient(conn)) diff --git a/cmd/dist/list.go b/cmd/dist/list.go index 2ba1d88..0a83445 100644 --- a/cmd/dist/list.go +++ b/cmd/dist/list.go @@ -54,7 +54,7 @@ var listCommand = cli.Command{ tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0) defer tw.Flush() - fmt.Fprintf(tw, "DIGEST\tSIZE\tAGE\n") + fmt.Fprintln(tw, "DIGEST\tSIZE\tAGE") walkFn = func(path string, fi os.FileInfo, dgst digest.Digest) error { fmt.Fprintf(tw, "%s\t%s\t%s\n", dgst,