From 45756b6d64c8373e41727fab9a8798eb10275f80 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 20 Feb 2018 17:37:35 -0800 Subject: [PATCH] fix a bunch of go vet errors License: MIT Signed-off-by: Steven Allen --- commands/legacy/request.go | 14 +++++++++++--- commands/legacy/response.go | 2 +- commands/request.go | 12 ++++++++++-- core/commands/get.go | 2 +- core/coreapi/block.go | 2 -- core/coreapi/object_test.go | 2 +- core/coreapi/unixfs.go | 2 +- core/corehttp/metrics_test.go | 2 +- 8 files changed, 26 insertions(+), 12 deletions(-) diff --git a/commands/legacy/request.go b/commands/legacy/request.go index 267920348..e0c65405c 100644 --- a/commands/legacy/request.go +++ b/commands/legacy/request.go @@ -77,7 +77,7 @@ func (r *requestWrapper) Option(name string) *cmdkit.OptionValue { optDefs, err := r.req.Root.GetOptions(r.req.Path) if err != nil { - return &cmdkit.OptionValue{nil, false, nil} + return &cmdkit.OptionValue{} } for _, def := range optDefs { for _, optName := range def.Names() { @@ -95,11 +95,19 @@ func (r *requestWrapper) Option(name string) *cmdkit.OptionValue { for _, n := range option.Names() { val, found := r.req.Options[n] if found { - return &cmdkit.OptionValue{val, found, option} + return &cmdkit.OptionValue{ + Value: val, + ValueFound: found, + Def: option, + } } } - return &cmdkit.OptionValue{option.Default(), false, option} + return &cmdkit.OptionValue{ + Value: option.Default(), + ValueFound: false, + Def: option, + } } func (r *requestWrapper) Options() cmdkit.OptMap { diff --git a/commands/legacy/response.go b/commands/legacy/response.go index 9a2f4b3e9..aa55ab189 100644 --- a/commands/legacy/response.go +++ b/commands/legacy/response.go @@ -155,7 +155,7 @@ func (r *fakeResponse) SetOutput(v interface{}) { _, isReader := v.(io.Reader) if t != nil && t.Kind() != reflect.Chan && !isReader { - v = cmds.Single{v} + v = cmds.Single{Value: v} } r.out = v diff --git a/commands/request.go b/commands/request.go index fd30d8064..361fdbe7f 100644 --- a/commands/request.go +++ b/commands/request.go @@ -161,11 +161,19 @@ func (r *request) Option(name string) *cmdkit.OptionValue { for _, n := range option.Names() { val, found := r.options[n] if found { - return &cmdkit.OptionValue{val, found, option} + return &cmdkit.OptionValue{ + Value: val, + ValueFound: found, + Def: option, + } } } - return &cmdkit.OptionValue{option.Default(), false, option} + return &cmdkit.OptionValue{ + Value: option.Default(), + ValueFound: false, + Def: option, + } } // Options returns a copy of the option map diff --git a/core/commands/get.go b/core/commands/get.go index e75331943..e8716f580 100644 --- a/core/commands/get.go +++ b/core/commands/get.go @@ -247,7 +247,7 @@ func (gw *getWriter) writeExtracted(r io.Reader, fpath string) error { defer bar.Finish() defer bar.Set64(gw.Size) - extractor := &tar.Extractor{fpath, bar.Add64} + extractor := &tar.Extractor{Path: fpath, Progress: bar.Add64} return extractor.Extract(r) } diff --git a/core/coreapi/block.go b/core/coreapi/block.go index a8a691c4d..176d562c2 100644 --- a/core/coreapi/block.go +++ b/core/coreapi/block.go @@ -111,8 +111,6 @@ func (api *BlockAPI) Rm(ctx context.Context, p coreiface.Path, opts ...caopts.Bl case <-ctx.Done(): return ctx.Err() } - - return nil } func (api *BlockAPI) Stat(ctx context.Context, p coreiface.Path) (coreiface.BlockStat, error) { diff --git a/core/coreapi/object_test.go b/core/coreapi/object_test.go index 1ff90d32d..a06d0e165 100644 --- a/core/coreapi/object_test.go +++ b/core/coreapi/object_test.go @@ -268,7 +268,7 @@ func TestObjectAddLinkCreate(t *testing.T) { t.Fatal("expected an error") } if err.Error() != "no link by that name" { - t.Fatal("unexpected error: %s", err.Error()) + t.Fatalf("unexpected error: %s", err.Error()) } p3, err = api.Object().AddLink(ctx, p2, "abc/d", p2, api.Object().WithCreate(true)) diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index 2138fa299..f6869619b 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -71,7 +71,7 @@ func (api *UnixfsAPI) Ls(ctx context.Context, p coreiface.Path) ([]*coreiface.Li links := make([]*coreiface.Link, len(ndlinks)) for i, l := range ndlinks { - links[i] = &coreiface.Link{l.Name, l.Size, l.Cid} + links[i] = &coreiface.Link{Name: l.Name, Size: l.Size, Cid: l.Cid} } return links, nil } diff --git a/core/corehttp/metrics_test.go b/core/corehttp/metrics_test.go index 1b94dffba..89ba5f2f2 100644 --- a/core/corehttp/metrics_test.go +++ b/core/corehttp/metrics_test.go @@ -45,6 +45,6 @@ func TestPeersTotal(t *testing.T) { t.Fatalf("expected 1 peers transport, got %d", len(actual)) } if actual["/ip4/tcp"] != float64(3) { - t.Fatalf("expected 3 peers, got %s", actual["/ip4/tcp"]) + t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"]) } }