chore: update code format. (#628)

This commit is contained in:
Bo-Yi Wu
2021-04-15 19:49:17 +08:00
committed by GitHub
parent 7e087de6e6
commit afd9ff889e
68 changed files with 390 additions and 414 deletions

View File

@@ -945,7 +945,6 @@ func (s *Redis) Pipelined(fn func(Pipeliner) error) (err error) {
_, err = conn.Pipelined(fn)
return err
}, acceptable)
return

View File

@@ -384,7 +384,6 @@ func TestRedis_BitCount(t *testing.T) {
val, err = client.BitCount("key", 2, 2)
assert.Nil(t, err)
assert.Equal(t, int64(0), val)
})
}
@@ -401,7 +400,7 @@ func TestRedis_BitOpAnd(t *testing.T) {
assert.Equal(t, int64(1), val)
valStr, err := client.Get("destKey")
assert.Nil(t, err)
//destKey binary 110000 ascii 0
// destKey binary 110000 ascii 0
assert.Equal(t, "0", valStr)
})
}
@@ -454,9 +453,10 @@ func TestRedis_BitOpXor(t *testing.T) {
assert.Equal(t, "\xf0", valStr)
})
}
func TestRedis_BitPos(t *testing.T) {
runOnRedis(t, func(client *Redis) {
//11111111 11110000 00000000
// 11111111 11110000 00000000
err := client.Set("key", "\xff\xf0\x00")
assert.Nil(t, err)
@@ -481,7 +481,6 @@ func TestRedis_BitPos(t *testing.T) {
val, err = client.BitPos("key", 1, 2, 2)
assert.Nil(t, err)
assert.Equal(t, int64(-1), val)
})
}
@@ -1035,7 +1034,7 @@ func TestRedisBlpopEx(t *testing.T) {
func TestRedisGeo(t *testing.T) {
runOnRedis(t, func(client *Redis) {
client.Ping()
var geoLocation = []*GeoLocation{{Longitude: 13.361389, Latitude: 38.115556, Name: "Palermo"}, {Longitude: 15.087269, Latitude: 37.502669, Name: "Catania"}}
geoLocation := []*GeoLocation{{Longitude: 13.361389, Latitude: 38.115556, Name: "Palermo"}, {Longitude: 15.087269, Latitude: 37.502669, Name: "Catania"}}
v, err := client.GeoAdd("sicily", geoLocation...)
assert.Nil(t, err)
assert.Equal(t, int64(2), v)
@@ -1053,7 +1052,7 @@ func TestRedisGeo(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, int64(v4[0].Dist), int64(190))
assert.Equal(t, int64(v4[1].Dist), int64(56))
var geoLocation2 = []*GeoLocation{{Longitude: 13.583333, Latitude: 37.316667, Name: "Agrigento"}}
geoLocation2 := []*GeoLocation{{Longitude: 13.583333, Latitude: 37.316667, Name: "Agrigento"}}
v5, err := client.GeoAdd("sicily", geoLocation2...)
assert.Nil(t, err)
assert.Equal(t, int64(1), v5)
@@ -1087,7 +1086,6 @@ func runOnRedis(t *testing.T, fn func(client *Redis)) {
}
}()
fn(NewRedis(s.Addr(), NodeType))
}
func runOnRedisTLS(t *testing.T, fn func(client *Redis)) {

View File

@@ -53,7 +53,8 @@ func NewRedisLock(store *Redis, key string) *RedisLock {
func (rl *RedisLock) Acquire() (bool, error) {
seconds := atomic.LoadUint32(&rl.seconds)
resp, err := rl.store.Eval(lockCommand, []string{rl.key}, []string{
rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance)})
rl.id, strconv.Itoa(int(seconds)*millisPerSecond + tolerance),
})
if err == red.Nil {
return false, nil
} else if err != nil {