From 804f8a18d056a937e45e29fc2e9773d06c88e41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= Date: Tue, 1 Dec 2015 08:23:30 -0600 Subject: [PATCH 1/4] Making errcheck happy. --- chainstore.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chainstore.go b/chainstore.go index b6512dd..3f5671a 100644 --- a/chainstore.go +++ b/chainstore.go @@ -85,7 +85,9 @@ func (c *Chain) Put(ctx context.Context, key string, val []byte) (err error) { return } if c.async { - go fn() + go func() { + _ = fn() + }() } else { err = fn() } @@ -149,7 +151,9 @@ func (c *Chain) Del(ctx context.Context, key string) (err error) { return } if c.async { - go fn() + go func() { + _ = fn() + }() } else { err = fn() } From 350f4f58aef6f49219bbf7d9ea2e5f64b8f59b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= Date: Tue, 1 Dec 2015 08:28:59 -0600 Subject: [PATCH 2/4] Fix for go1.3 --- chainstore_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chainstore_test.go b/chainstore_test.go index a1c3434..b55c3fa 100644 --- a/chainstore_test.go +++ b/chainstore_test.go @@ -86,6 +86,8 @@ func TestAsyncChain(t *testing.T) { var errored atomic.Value + errored.Store(false) + ms = memstore.New(100) fs = filestore.New(storeDir+"/filestore", 0755) bs = boltstore.New(storeDir+"/boltstore/bolt.db", "test") @@ -138,13 +140,13 @@ func TestAsyncChain(t *testing.T) { //-- // Lets make an error in async store - assert.Nil(errored.Load()) + assert.False(errored.Load().(bool)) err = chain.Put(ctx, "bad", []byte("v")) assert.Nil(err) // no error because sync store took it fine time.Sleep(time.Second * 1) // wait for async operation.. - assert.NotEmpty(errored.Load()) + assert.True(errored.Load().(bool)) } type testStore struct{} From 65a5709aa30b39626966edad8ab0954f573c03be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= Date: Tue, 1 Dec 2015 08:41:33 -0600 Subject: [PATCH 3/4] Nope, removing go1.3 from travis. Support for atomic.Value was not available until go1.4. --- .travis.yml | 1 - chainstore_test.go | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96a5cdf..9ad8d48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: go go: - - 1.3 - 1.4 - release - tip diff --git a/chainstore_test.go b/chainstore_test.go index b55c3fa..e1e88e6 100644 --- a/chainstore_test.go +++ b/chainstore_test.go @@ -86,8 +86,6 @@ func TestAsyncChain(t *testing.T) { var errored atomic.Value - errored.Store(false) - ms = memstore.New(100) fs = filestore.New(storeDir+"/filestore", 0755) bs = boltstore.New(storeDir+"/boltstore/bolt.db", "test") @@ -140,13 +138,13 @@ func TestAsyncChain(t *testing.T) { //-- // Lets make an error in async store - assert.False(errored.Load().(bool)) + assert.Nil(errored.Load()) err = chain.Put(ctx, "bad", []byte("v")) assert.Nil(err) // no error because sync store took it fine time.Sleep(time.Second * 1) // wait for async operation.. - assert.True(errored.Load().(bool)) + assert.NotNil(errored.Load()) } type testStore struct{} From 8f1248911b564a39713e4592d4cb6ee3380cc5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= Date: Tue, 1 Dec 2015 09:09:04 -0600 Subject: [PATCH 4/4] Removing errcheck program. --- .travis.yml | 4 ---- chainstore.go | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ad8d48..283a803 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,5 @@ go: - tip script: - - go get github.com/kisielk/errcheck - go get -t ./... - - go test -tags "skipexternal" -v -race ./... - - errcheck github.com/pressly/chainstore - diff --git a/chainstore.go b/chainstore.go index 3f5671a..b6512dd 100644 --- a/chainstore.go +++ b/chainstore.go @@ -85,9 +85,7 @@ func (c *Chain) Put(ctx context.Context, key string, val []byte) (err error) { return } if c.async { - go func() { - _ = fn() - }() + go fn() } else { err = fn() } @@ -151,9 +149,7 @@ func (c *Chain) Del(ctx context.Context, key string) (err error) { return } if c.async { - go func() { - _ = fn() - }() + go fn() } else { err = fn() }