Update staticcheck version and fix all warnings (#1381)

This commit is contained in:
Ta-Ching Chen
2019-11-05 18:09:12 +08:00
committed by GitHub
parent 93d4b88d84
commit b9a5588ca9
43 changed files with 122 additions and 219 deletions
+2 -2
View File
@@ -159,7 +159,7 @@ func (c *Cache) Get(key interface{}) (interface{}, error) {
// if key exists in the cache, the new value is NOT set; instead an
// error and the old value are returned
func (c *Cache) Set(key interface{}, value interface{}) (error, interface{}) {
func (c *Cache) Set(key interface{}, value interface{}) (interface{}, error) {
respChannel := make(chan *response)
c.requestChannel <- &request{
requestType: SET,
@@ -168,7 +168,7 @@ func (c *Cache) Set(key interface{}, value interface{}) (error, interface{}) {
responseChannel: respChannel,
}
resp := <-respChannel
return resp.error, resp.existingValue
return resp.existingValue, resp.error
}
func (c *Cache) Delete(key interface{}) error {
+3 -3
View File
@@ -31,9 +31,9 @@ func checkErr(err error) {
func TestCache(t *testing.T) {
c := MakeCache(100*time.Millisecond, 100*time.Millisecond)
err, _ := c.Set("a", "b")
_, err := c.Set("a", "b")
checkErr(err)
err, _ = c.Set("p", "q")
_, err = c.Set("p", "q")
checkErr(err)
val, err := c.Get("a")
@@ -55,7 +55,7 @@ func TestCache(t *testing.T) {
log.Panicf("found deleted element")
}
err, _ = c.Set("expires", "42")
_, err = c.Set("expires", "42")
checkErr(err)
time.Sleep(150 * time.Millisecond)
_, err = c.Get("expires")