@cryptotaxi247 / kubo / commits / 6546aeade

fix: multiple govet warnings

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Mar 24, 2017 at 01:02 UTC 6546aeade79b58c8fdba463cab9015146394f5c3
12 files changed +30 -20
blocks/blockstore/blockstore.go
+2 -2
@@ -198,14 +198,14 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
198 return
199 }
200 if e.Error != nil {
201 - log.Errorf("blockstore.AllKeysChan got err:", e.Error)
201 + log.Errorf("blockstore.AllKeysChan got err: %s", e.Error)
202 return
203 }
204
205 // need to convert to key.Key using key.KeyFromDsKey.
206 k, err := dshelp.DsKeyToCid(ds.RawKey(e.Key))
207 if err != nil {
208 - log.Warningf("error parsing key from DsKey: ", err)
208 + log.Warningf("error parsing key from DsKey: %s", err)
209 continue
210 }
211
blocks/blockstore/bloom_cache_test.go
+6 -2
@@ -31,7 +31,9 @@ func testBloomCached(bs Blockstore, ctx context.Context) (*bloomcache, error) {
31 func TestPutManyAddsToBloom(t *testing.T) {
32 bs := NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
33
34 - ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
34 + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
35 + defer cancel()
36 +
37 cachedbs, err := testBloomCached(bs, ctx)
38
39 select {
@@ -75,7 +77,9 @@ func TestHasIsBloomCached(t *testing.T) {
77 for i := 0; i < 1000; i++ {
78 bs.Put(blocks.NewBlock([]byte(fmt.Sprintf("data: %d", i))))
79 }
78 - ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
80 + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
81 + defer cancel()
82 +
83 cachedbs, err := testBloomCached(bs, ctx)
84 if err != nil {
85 t.Fatal(err)
blockservice/blockservice_test.go
+1 -1
@@ -32,7 +32,7 @@ func TestWriteThroughWorks(t *testing.T) {
32
33 bserv.AddBlock(block)
34 if bstore.PutCounter != 2 {
35 - t.Fatal("Put should have called again, should be 2 is: %d", bstore.PutCounter)
35 + t.Fatalf("Put should have called again, should be 2 is: %d", bstore.PutCounter)
36 }
37 }
38
cmd/ipfswatch/main.go
+5 -3
@@ -1,21 +1,24 @@
1 package main
2
3 import (
4 + "context"
5 "flag"
6 "log"
7 "os"
8 "os/signal"
9 "path/filepath"
10
10 - context "context"
11 - homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
11 commands "github.com/ipfs/go-ipfs/commands"
12 core "github.com/ipfs/go-ipfs/core"
13 corehttp "github.com/ipfs/go-ipfs/core/corehttp"
14 coreunix "github.com/ipfs/go-ipfs/core/coreunix"
15 config "github.com/ipfs/go-ipfs/repo/config"
16 fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
17 +
18 + homedir "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"
19 +
20 process "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
21 +
22 fsnotify "gx/ipfs/QmczzCMvJ3HV57WBKDy8b4ucp7quT325JjDbixYRS5Pwvv/fsnotify.v1"
23 )
24
@@ -141,7 +144,6 @@ func run(ipfsPath, watchPath string) error {
144 log.Println(err)
145 }
146 }
144 - return nil
147 }
148
149 func addTree(w *fsnotify.Watcher, root string) error {
commands/http/handler.go
+3 -4
@@ -1,6 +1,7 @@
1 package http
2
3 import (
4 + "context"
5 "errors"
6 "fmt"
7 "io"
@@ -11,11 +12,10 @@ import (
12 "strings"
13 "sync"
14
14 - context "context"
15 + cmds "github.com/ipfs/go-ipfs/commands"
16 "github.com/ipfs/go-ipfs/repo/config"
16 - cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors"
17
18 - cmds "github.com/ipfs/go-ipfs/commands"
18 + cors "gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors"
19 logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
20 )
21
@@ -323,7 +323,6 @@ func flushCopy(w io.Writer, r io.Reader) error {
323
324 f.Flush()
325 }
326 - return nil
326 }
327
328 func sanitizedErrStr(err error) string {
core/coreapi/unixfs_test.go
+2 -2
@@ -205,7 +205,7 @@ func TestCatOffline(t *testing.T) {
205
206 _, err = api.Cat(ctx, coreapi.ResolvedPath("/ipns/Qmfoobar", nil, nil))
207 if err != coreiface.ErrOffline {
208 - t.Fatalf("expected ErrOffline, got: %", err)
208 + t.Fatalf("expected ErrOffline, got: %s", err)
209 }
210 }
211
@@ -223,7 +223,7 @@ func TestLs(t *testing.T) {
223 }
224 parts := strings.Split(k, "/")
225 if len(parts) != 2 {
226 - t.Errorf("unexpected path:", k)
226 + t.Errorf("unexpected path: %s", k)
227 }
228 p := coreapi.ResolvedPath("/ipfs/"+parts[0], nil, nil)
229
filestore/filestore.go
+1
@@ -36,6 +36,7 @@ func (f *Filestore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) {
36
37 a, err := f.bs.AllKeysChan(ctx)
38 if err != nil {
39 + cancel()
40 return nil, err
41 }
42
fuse/ipns/ipns_unix.go
-2
@@ -126,8 +126,6 @@ func loadRoot(ctx context.Context, rt *keyRoot, ipfs *core.IpfsNode, name string
126 default:
127 return nil, errors.New("unrecognized type")
128 }
129 -
130 - panic("not reached")
129 }
130
131 type keyRoot struct {
path/path_test.go
+1 -1
@@ -24,7 +24,7 @@ func TestPathParsing(t *testing.T) {
24 _, err := ParsePath(p)
25 valid := (err == nil)
26 if valid != expected {
27 - t.Fatalf("expected %s to have valid == %s", p, expected)
27 + t.Fatalf("expected %s to have valid == %t", p, expected)
28 }
29 }
30 }
pin/pin_test.go
+5 -2
@@ -341,7 +341,9 @@ func TestPinRecursiveFail(t *testing.T) {
341 }
342
343 // NOTE: This isnt a time based test, we expect the pin to fail
344 - mctx, _ := context.WithTimeout(ctx, time.Millisecond)
344 + mctx, cancel := context.WithTimeout(ctx, time.Millisecond)
345 + defer cancel()
346 +
347 err = p.Pin(mctx, a, true)
348 if err == nil {
349 t.Fatal("should have failed to pin here")
@@ -358,7 +360,8 @@ func TestPinRecursiveFail(t *testing.T) {
360 }
361
362 // this one is time based... but shouldnt cause any issues
361 - mctx, _ = context.WithTimeout(ctx, time.Second)
363 + mctx, cancel = context.WithTimeout(ctx, time.Second)
364 + defer cancel()
365 err = p.Pin(mctx, a, true)
366 if err != nil {
367 t.Fatal(err)
pin/set_test.go
+1 -1
@@ -95,7 +95,7 @@ func TestSet(t *testing.T) {
95
96 for _, c := range inputs {
97 if !seen.Has(c) {
98 - t.Fatalf("expected to have %s, didnt find it")
98 + t.Fatalf("expected to have '%s', didnt find it", c)
99 }
100 }
101 }
unixfs/mod/dagmodifier.go
+3
@@ -336,15 +336,18 @@ func (dm *DagModifier) readPrep() error {
336 ctx, cancel := context.WithCancel(dm.ctx)
337 dr, err := uio.NewDagReader(ctx, dm.curNode, dm.dagserv)
338 if err != nil {
339 + cancel()
340 return err
341 }
342
343 i, err := dr.Seek(int64(dm.curWrOff), os.SEEK_SET)
344 if err != nil {
345 + cancel()
346 return err
347 }
348
349 if i != int64(dm.curWrOff) {
350 + cancel()
351 return ErrSeekFail
352 }
353