Skip to content

Commit f9e4205

Browse files
committed
golint util/, thirdparty/
and exchange/bitswap/testutils.go License: MIT Signed-off-by: rht <[email protected]>
1 parent 91548ef commit f9e4205

File tree

11 files changed

+34
-36
lines changed

11 files changed

+34
-36
lines changed

exchange/bitswap/testutils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (g *SessionGenerator) Next() Instance {
5050
}
5151

5252
func (g *SessionGenerator) Instances(n int) []Instance {
53-
instances := make([]Instance, 0)
53+
var instances []Instance
5454
for j := 0; j < n; j++ {
5555
inst := g.Next()
5656
instances = append(instances, inst)

test/integration/addcat_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestDegenerateSlowRouting(t *testing.T) {
6161

6262
func Test100MBMacbookCoastToCoast(t *testing.T) {
6363
SkipUnlessEpic(t)
64-
conf := testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
64+
conf := testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
6565
if err := DirectAddCat(RandomBytes(100*1024*1024), conf); err != nil {
6666
t.Fatal(err)
6767
}

test/integration/bench_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B)
2121
}
2222
}
2323

24-
var instant = testutil.LatencyConfig{}.All_Instantaneous()
24+
var instant = testutil.LatencyConfig{}.AllInstantaneous()
2525

2626
func BenchmarkInstantaneousAddCat1KB(b *testing.B) { benchmarkAddCat(1*unit.KB, instant, b) }
2727
func BenchmarkInstantaneousAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, instant, b) }
@@ -34,7 +34,7 @@ func BenchmarkInstantaneousAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.M
3434
func BenchmarkInstantaneousAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, instant, b) }
3535
func BenchmarkInstantaneousAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, instant, b) }
3636

37-
var routing = testutil.LatencyConfig{}.Routing_Slow()
37+
var routing = testutil.LatencyConfig{}.RoutingSlow()
3838

3939
func BenchmarkRoutingSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, routing, b) }
4040
func BenchmarkRoutingSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, routing, b) }
@@ -47,7 +47,7 @@ func BenchmarkRoutingSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB
4747
func BenchmarkRoutingSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, routing, b) }
4848
func BenchmarkRoutingSlowAddCat512MB(b *testing.B) { benchmarkAddCat(512*unit.MB, routing, b) }
4949

50-
var network = testutil.LatencyConfig{}.Network_NYtoSF()
50+
var network = testutil.LatencyConfig{}.NetworkNYtoSF()
5151

5252
func BenchmarkNetworkSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, network, b) }
5353
func BenchmarkNetworkSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, network, b) }
@@ -59,7 +59,7 @@ func BenchmarkNetworkSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.MB,
5959
func BenchmarkNetworkSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, network, b) }
6060
func BenchmarkNetworkSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, network, b) }
6161

62-
var hdd = testutil.LatencyConfig{}.Blockstore_7200RPM()
62+
var hdd = testutil.LatencyConfig{}.Blockstore7200RPM()
6363

6464
func BenchmarkBlockstoreSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, hdd, b) }
6565
func BenchmarkBlockstoreSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, hdd, b) }
@@ -71,7 +71,7 @@ func BenchmarkBlockstoreSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.
7171
func BenchmarkBlockstoreSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, hdd, b) }
7272
func BenchmarkBlockstoreSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, hdd, b) }
7373

74-
var mixed = testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
74+
var mixed = testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
7575

7676
func BenchmarkMixedAddCat1MBXX(b *testing.B) { benchmarkAddCat(1*unit.MB, mixed, b) }
7777
func BenchmarkMixedAddCat2MBXX(b *testing.B) { benchmarkAddCat(2*unit.MB, mixed, b) }

test/integration/three_legged_cat_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestThreeLeggedCatDegenerateSlowRouting(t *testing.T) {
5555

5656
func TestThreeLeggedCat100MBMacbookCoastToCoast(t *testing.T) {
5757
SkipUnlessEpic(t)
58-
conf := testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
58+
conf := testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
5959
if err := RunThreeLeggedCat(RandomBytes(100*unit.MB), conf); err != nil {
6060
t.Fatal(err)
6161
}

thirdparty/eventlog/loggable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func (l LoggableMap) Loggable() map[string]interface{} {
1111
return l
1212
}
1313

14-
// Loggable converts a func into a Loggable
14+
// LoggableF converts a func into a Loggable
1515
type LoggableF func() map[string]interface{}
1616

1717
func (l LoggableF) Loggable() map[string]interface{} {

thirdparty/notifier/notifier.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (n *Notifier) Notify(e Notifiee) {
7171
n.mu.Unlock()
7272
}
7373

74-
// StopNotifying stops notifying Notifiee e. This function
74+
// StopNotify stops notifying Notifiee e. This function
7575
// is meant to be called behind your own type-safe function(s):
7676
//
7777
// // generic function for pattern-following

thirdparty/redis-datastore/datastore.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ import (
1111
query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
1212
)
1313

14-
var _ datastore.Datastore = &RedisDatastore{}
15-
var _ datastore.ThreadSafeDatastore = &RedisDatastore{}
14+
var _ datastore.Datastore = &Datastore{}
15+
var _ datastore.ThreadSafeDatastore = &Datastore{}
1616

1717
var ErrInvalidType = errors.New("redis datastore: invalid type error. this datastore only supports []byte values")
1818

1919
func NewExpiringDatastore(client *redis.Client, ttl time.Duration) (datastore.ThreadSafeDatastore, error) {
20-
return &RedisDatastore{
20+
return &Datastore{
2121
client: client,
2222
ttl: ttl,
2323
}, nil
2424
}
2525

2626
func NewDatastore(client *redis.Client) (datastore.ThreadSafeDatastore, error) {
27-
return &RedisDatastore{
27+
return &Datastore{
2828
client: client,
2929
}, nil
3030
}
3131

32-
type RedisDatastore struct {
32+
type Datastore struct {
3333
mu sync.Mutex
3434
client *redis.Client
3535
ttl time.Duration
3636
}
3737

38-
func (ds *RedisDatastore) Put(key datastore.Key, value interface{}) error {
38+
func (ds *Datastore) Put(key datastore.Key, value interface{}) error {
3939
ds.mu.Lock()
4040
defer ds.mu.Unlock()
4141

@@ -59,26 +59,26 @@ func (ds *RedisDatastore) Put(key datastore.Key, value interface{}) error {
5959
return nil
6060
}
6161

62-
func (ds *RedisDatastore) Get(key datastore.Key) (value interface{}, err error) {
62+
func (ds *Datastore) Get(key datastore.Key) (value interface{}, err error) {
6363
ds.mu.Lock()
6464
defer ds.mu.Unlock()
6565
return ds.client.Cmd("GET", key.String()).Bytes()
6666
}
6767

68-
func (ds *RedisDatastore) Has(key datastore.Key) (exists bool, err error) {
68+
func (ds *Datastore) Has(key datastore.Key) (exists bool, err error) {
6969
ds.mu.Lock()
7070
defer ds.mu.Unlock()
7171
return ds.client.Cmd("EXISTS", key.String()).Bool()
7272
}
7373

74-
func (ds *RedisDatastore) Delete(key datastore.Key) (err error) {
74+
func (ds *Datastore) Delete(key datastore.Key) (err error) {
7575
ds.mu.Lock()
7676
defer ds.mu.Unlock()
7777
return ds.client.Cmd("DEL", key.String()).Err
7878
}
7979

80-
func (ds *RedisDatastore) Query(q query.Query) (query.Results, error) {
80+
func (ds *Datastore) Query(q query.Query) (query.Results, error) {
8181
return nil, errors.New("TODO implement query for redis datastore?")
8282
}
8383

84-
func (ds *RedisDatastore) IsThreadSafe() {}
84+
func (ds *Datastore) IsThreadSafe() {}

thirdparty/unit/unit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (i Information) String() string {
1919
tmp := int64(i)
2020

2121
// default
22-
var d int64 = tmp
22+
var d = tmp
2323
symbol := "B"
2424

2525
switch {

util/testutil/gen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (p *PeerNetParams) checkKeys() error {
122122
return fmt.Errorf("sig verify failed: %s", err)
123123
}
124124
if !sigok {
125-
return fmt.Errorf("sig verify failed: sig invalid!")
125+
return fmt.Errorf("sig verify failed: sig invalid")
126126
}
127127

128128
return nil // ok. move along.

util/testutil/latency_config.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,41 @@ type LatencyConfig struct {
88
RoutingLatency time.Duration
99
}
1010

11-
func (c LatencyConfig) All_Instantaneous() LatencyConfig {
11+
func (c LatencyConfig) AllInstantaneous() LatencyConfig {
1212
// Could use a zero value but whatever. Consistency of interface
1313
c.NetworkLatency = 0
1414
c.RoutingLatency = 0
1515
c.BlockstoreLatency = 0
1616
return c
1717
}
1818

19-
func (c LatencyConfig) Network_NYtoSF() LatencyConfig {
19+
func (c LatencyConfig) NetworkNYtoSF() LatencyConfig {
2020
c.NetworkLatency = 20 * time.Millisecond
2121
return c
2222
}
2323

24-
func (c LatencyConfig) Network_IntraDatacenter2014() LatencyConfig {
24+
func (c LatencyConfig) NetworkIntraDatacenter2014() LatencyConfig {
2525
c.NetworkLatency = 250 * time.Microsecond
2626
return c
2727
}
2828

29-
func (c LatencyConfig) Blockstore_FastSSD2014() LatencyConfig {
29+
func (c LatencyConfig) BlockstoreFastSSD2014() LatencyConfig {
3030
const iops = 100000
3131
c.BlockstoreLatency = (1 / iops) * time.Second
3232
return c
3333
}
3434

35-
func (c LatencyConfig) Blockstore_SlowSSD2014() LatencyConfig {
35+
func (c LatencyConfig) BlockstoreSlowSSD2014() LatencyConfig {
3636
c.BlockstoreLatency = 150 * time.Microsecond
3737
return c
3838
}
3939

40-
func (c LatencyConfig) Blockstore_7200RPM() LatencyConfig {
40+
func (c LatencyConfig) Blockstore7200RPM() LatencyConfig {
4141
c.BlockstoreLatency = 8 * time.Millisecond
4242
return c
4343
}
4444

45-
func (c LatencyConfig) Routing_Slow() LatencyConfig {
45+
func (c LatencyConfig) RoutingSlow() LatencyConfig {
4646
c.RoutingLatency = 200 * time.Millisecond
4747
return c
4848
}

util/util.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// package util implements various utility functions used within ipfs
1+
// Package util implements various utility functions used within ipfs
22
// that do not currently have a better place to live.
33
package util
44

@@ -95,7 +95,7 @@ func GetenvBool(name string) bool {
9595
return v == "true" || v == "t" || v == "1"
9696
}
9797

98-
// multiErr is a util to return multiple errors
98+
// MultiErr is a util to return multiple errors
9999
type MultiErr []error
100100

101101
func (m MultiErr) Error() string {
@@ -116,17 +116,15 @@ func (m MultiErr) Error() string {
116116
func Partition(subject string, sep string) (string, string, string) {
117117
if i := strings.Index(subject, sep); i != -1 {
118118
return subject[:i], subject[i : i+len(sep)], subject[i+len(sep):]
119-
} else {
120-
return subject, "", ""
121119
}
120+
return subject, "", ""
122121
}
123122

124123
func RPartition(subject string, sep string) (string, string, string) {
125124
if i := strings.LastIndex(subject, sep); i != -1 {
126125
return subject[:i], subject[i : i+len(sep)], subject[i+len(sep):]
127-
} else {
128-
return subject, "", ""
129126
}
127+
return subject, "", ""
130128
}
131129

132130
// Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits

0 commit comments

Comments
 (0)