fix a bunch of go vet errors

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen 2018-02-20 17:37:35 -08:00
parent 868855f625
commit 45756b6d64
8 changed files with 26 additions and 12 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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)
}

View File

@ -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) {

View File

@ -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))

View File

@ -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
}

View File

@ -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"])
}
}