mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 01:52:26 +08:00
Merge pull request #3824 from ipfs/fix/govet/some-error
fix: multiple govet warnings
This commit is contained in:
@ -6,6 +6,7 @@ exclude_paths:
|
||||
- test/
|
||||
- Godeps/
|
||||
- thirdparty/
|
||||
- "**/*.pb.go"
|
||||
|
||||
engines:
|
||||
fixme:
|
||||
|
@ -198,14 +198,14 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
|
||||
return
|
||||
}
|
||||
if e.Error != nil {
|
||||
log.Errorf("blockstore.AllKeysChan got err:", e.Error)
|
||||
log.Errorf("blockstore.AllKeysChan got err: %s", e.Error)
|
||||
return
|
||||
}
|
||||
|
||||
// need to convert to key.Key using key.KeyFromDsKey.
|
||||
k, err := dshelp.DsKeyToCid(ds.RawKey(e.Key))
|
||||
if err != nil {
|
||||
log.Warningf("error parsing key from DsKey: ", err)
|
||||
log.Warningf("error parsing key from DsKey: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,9 @@ func testBloomCached(bs Blockstore, ctx context.Context) (*bloomcache, error) {
|
||||
func TestPutManyAddsToBloom(t *testing.T) {
|
||||
bs := NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
|
||||
cachedbs, err := testBloomCached(bs, ctx)
|
||||
|
||||
select {
|
||||
@ -75,7 +77,9 @@ func TestHasIsBloomCached(t *testing.T) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
bs.Put(blocks.NewBlock([]byte(fmt.Sprintf("data: %d", i))))
|
||||
}
|
||||
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
|
||||
cachedbs, err := testBloomCached(bs, ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -32,7 +32,7 @@ func TestWriteThroughWorks(t *testing.T) {
|
||||
|
||||
bserv.AddBlock(block)
|
||||
if bstore.PutCounter != 2 {
|
||||
t.Fatal("Put should have called again, should be 2 is: %d", bstore.PutCounter)
|
||||
t.Fatalf("Put should have called again, should be 2 is: %d", bstore.PutCounter)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
|
||||
context "context"
|
||||
homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
|
||||
commands "github.com/ipfs/go-ipfs/commands"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
corehttp "github.com/ipfs/go-ipfs/core/corehttp"
|
||||
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
|
||||
config "github.com/ipfs/go-ipfs/repo/config"
|
||||
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
|
||||
|
||||
homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
|
||||
|
||||
process "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
|
||||
|
||||
fsnotify "gx/ipfs/QmczzCMvJ3HV57WBKDy8b4ucp7quT325JjDbixYRS5Pwvv/fsnotify.v1"
|
||||
)
|
||||
|
||||
@ -141,7 +144,6 @@ func run(ipfsPath, watchPath string) error {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func addTree(w *fsnotify.Watcher, root string) error {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -11,11 +12,10 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
context "context"
|
||||
"github.com/ipfs/go-ipfs/repo/config"
|
||||
cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors"
|
||||
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
"github.com/ipfs/go-ipfs/repo/config"
|
||||
|
||||
cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors"
|
||||
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
|
||||
)
|
||||
|
||||
@ -323,7 +323,6 @@ func flushCopy(w io.Writer, r io.Reader) error {
|
||||
|
||||
f.Flush()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sanitizedErrStr(err error) string {
|
||||
|
@ -205,7 +205,7 @@ func TestCatOffline(t *testing.T) {
|
||||
|
||||
_, err = api.Cat(ctx, coreapi.ResolvedPath("/ipns/Qmfoobar", nil, nil))
|
||||
if err != coreiface.ErrOffline {
|
||||
t.Fatalf("expected ErrOffline, got: %", err)
|
||||
t.Fatalf("expected ErrOffline, got: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ func TestLs(t *testing.T) {
|
||||
}
|
||||
parts := strings.Split(k, "/")
|
||||
if len(parts) != 2 {
|
||||
t.Errorf("unexpected path:", k)
|
||||
t.Errorf("unexpected path: %s", k)
|
||||
}
|
||||
p := coreapi.ResolvedPath("/ipfs/"+parts[0], nil, nil)
|
||||
|
||||
|
@ -36,6 +36,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) {
|
||||
|
||||
a, err := f.bs.AllKeysChan(ctx)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -125,8 +125,6 @@ func loadRoot(ctx context.Context, rt *keyRoot, ipfs *core.IpfsNode, name string
|
||||
default:
|
||||
return nil, errors.New("unrecognized type")
|
||||
}
|
||||
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
type keyRoot struct {
|
||||
|
@ -24,7 +24,7 @@ func TestPathParsing(t *testing.T) {
|
||||
_, err := ParsePath(p)
|
||||
valid := (err == nil)
|
||||
if valid != expected {
|
||||
t.Fatalf("expected %s to have valid == %s", p, expected)
|
||||
t.Fatalf("expected %s to have valid == %t", p, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,9 @@ func TestPinRecursiveFail(t *testing.T) {
|
||||
}
|
||||
|
||||
// NOTE: This isnt a time based test, we expect the pin to fail
|
||||
mctx, _ := context.WithTimeout(ctx, time.Millisecond)
|
||||
mctx, cancel := context.WithTimeout(ctx, time.Millisecond)
|
||||
defer cancel()
|
||||
|
||||
err = p.Pin(mctx, a, true)
|
||||
if err == nil {
|
||||
t.Fatal("should have failed to pin here")
|
||||
@ -358,7 +360,8 @@ func TestPinRecursiveFail(t *testing.T) {
|
||||
}
|
||||
|
||||
// this one is time based... but shouldnt cause any issues
|
||||
mctx, _ = context.WithTimeout(ctx, time.Second)
|
||||
mctx, cancel = context.WithTimeout(ctx, time.Second)
|
||||
defer cancel()
|
||||
err = p.Pin(mctx, a, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -95,7 +95,7 @@ func TestSet(t *testing.T) {
|
||||
|
||||
for _, c := range inputs {
|
||||
if !seen.Has(c) {
|
||||
t.Fatalf("expected to have %s, didnt find it")
|
||||
t.Fatalf("expected to have '%s', didnt find it", c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,15 +336,18 @@ func (dm *DagModifier) readPrep() error {
|
||||
ctx, cancel := context.WithCancel(dm.ctx)
|
||||
dr, err := uio.NewDagReader(ctx, dm.curNode, dm.dagserv)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return err
|
||||
}
|
||||
|
||||
i, err := dr.Seek(int64(dm.curWrOff), os.SEEK_SET)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return err
|
||||
}
|
||||
|
||||
if i != int64(dm.curWrOff) {
|
||||
cancel()
|
||||
return ErrSeekFail
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user