Skip to content

Commit

Permalink
Merge pull request #203 from jbenet/govet
Browse files Browse the repository at this point in the history
go-vet friendly code
  • Loading branch information
jbenet committed Oct 25, 2014
2 parents 762faa7 + 184c254 commit 2ce4187
Show file tree
Hide file tree
Showing 59 changed files with 278 additions and 209 deletions.
8 changes: 4 additions & 4 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion blocks/set/dbset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type datastoreBlockSet struct {
bset BlockSet
}

// NewDBWrapperSet returns a new blockset wrapping a given datastore
func NewDBWrapperSet(d ds.Datastore, bset BlockSet) BlockSet {
return &datastoreBlockSet{
dstore: d,
Expand All @@ -21,7 +22,7 @@ func NewDBWrapperSet(d ds.Datastore, bset BlockSet) BlockSet {
func (d *datastoreBlockSet) AddBlock(k util.Key) {
err := d.dstore.Put(k.DsKey(), []byte{})
if err != nil {
log.Error("blockset put error: %s", err)
log.Errorf("blockset put error: %s", err)
}

d.bset.AddBlock(k)
Expand Down
8 changes: 4 additions & 4 deletions commands/cli/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func TestOptionParsing(t *testing.T) {
t.Error("Should have passed")
}
if len(opts) != 4 || opts["beep"] != "" || opts["boop"] != "lol" || opts["c"] != "" || opts["foo"] != "5" {
t.Error("Returned options were defferent than expected: %v", opts)
t.Errorf("Returned options were defferent than expected: %v", opts)
}
if len(input) != 2 || input[0] != "test2" || input[1] != "beep" {
t.Error("Returned input was different than expected: %v", input)
t.Errorf("Returned input was different than expected: %v", input)
}

_, _, err = parseOptions([]string{"-beep=1", "-boop=2", "-beep=3"})
Expand All @@ -39,9 +39,9 @@ func TestOptionParsing(t *testing.T) {

path, args := parsePath([]string{"test", "beep", "boop"}, cmd)
if len(path) != 1 || path[0] != "test" {
t.Error("Returned path was defferent than expected: %v", path)
t.Errorf("Returned path was defferent than expected: %v", path)
}
if len(args) != 2 || args[0] != "beep" || args[1] != "boop" {
t.Error("Returned args were different than expected: %v", args)
t.Errorf("Returned args were different than expected: %v", args)
}
}
4 changes: 2 additions & 2 deletions commands/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func TestOptionValidation(t *testing.T) {
req = NewEmptyRequest()
req.SetOption("b", ":)")
res = cmd.Call(req)
if res.Error == nil {
t.Error(res.Error, "Should have failed (string value not convertible to int)")
if res.Error() == nil {
t.Error(res.Error(), "Should have failed (string value not convertible to int)")
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/commands/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func printRefs(n *core.IpfsNode, nd *mdag.Node, refSeen map[u.Key]bool, recursiv
if recursive {
nd, err := n.DAG.Get(u.Key(link.Hash))
if err != nil {
log.Error("error: cannot retrieve %s (%s)\n", link.Hash.B58String(), err)
log.Errorf("error: cannot retrieve %s (%s)", link.Hash.B58String(), err)
return
}

Expand Down
10 changes: 5 additions & 5 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"fmt"

context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"

bserv "github.com/jbenet/go-ipfs/blockservice"
Expand Down Expand Up @@ -230,25 +230,25 @@ func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.P
func initConnections(ctx context.Context, cfg *config.Config, pstore peer.Peerstore, route *dht.IpfsDHT) {
for _, p := range cfg.Bootstrap {
if p.PeerID == "" {
log.Error("error: peer does not include PeerID. %v", p)
log.Errorf("error: peer does not include PeerID. %v", p)
}

maddr, err := ma.NewMultiaddr(p.Address)
if err != nil {
log.Error("%s", err)
log.Error(err)
continue
}

// setup peer
npeer, err := pstore.Get(peer.DecodePrettyID(p.PeerID))
if err != nil {
log.Error("Bootstrapping error: %v", err)
log.Errorf("Bootstrapping error: %v", err)
continue
}
npeer.AddAddress(maddr)

if _, err = route.Connect(ctx, npeer); err != nil {
log.Error("Bootstrapping error: %v", err)
log.Errorf("Bootstrapping error: %v", err)
}
}
}
6 changes: 3 additions & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func NewDaemonListener(ipfsnode *core.IpfsNode, addr ma.Multiaddr, confdir strin

ofi, err := os.Create(confdir + "/rpcaddress")
if err != nil {
log.Warning("Could not create rpcaddress file: %s", err)
log.Warningf("Could not create rpcaddress file: %s", err)
return nil, err
}

_, err = ofi.Write([]byte(addr.String()))
if err != nil {
log.Warning("Could not write to rpcaddress file: %s", err)
log.Warningf("Could not write to rpcaddress file: %s", err)
return nil, err
}
ofi.Close()
Expand Down Expand Up @@ -148,7 +148,7 @@ func (dl *DaemonListener) handleConnection(conn manet.Conn) {
err = fmt.Errorf("Invalid Command: '%s'", command.Command)
}
if err != nil {
log.Error("%s: %s", command.Command, err)
log.Errorf("%s: %s", command.Command, err)
fmt.Fprintln(conn, err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/daemon_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func serverIsRunning(confdir string) bool {
var err error
confdir, err = u.TildeExpansion(confdir)
if err != nil {
log.Error("Tilde Expansion Failed: %s", err)
log.Errorf("Tilde Expansion Failed: %s", err)
return false
}
lk, err := daemonLock(confdir)
Expand Down
Loading

0 comments on commit 2ce4187

Please sign in to comment.