Skip to content

Commit e8ad794

Browse files
Format code and fix go vet (#2696)
* run go fix ./... Signed-off-by: Tiago Peczenyj <[email protected]> * run make fmt Signed-off-by: Tiago Peczenyj <[email protected]> * fix go vet ./... issues * Update README.md Reorder imports with the rules defined in the Makefile as if we run `make fmt` * run gofumpt -w . * update Makefile to use gofumpt instead gofmt * increment makefile * format test * format tests Signed-off-by: Tiago Peczenyj <[email protected]> --------- Signed-off-by: Tiago Peczenyj <[email protected]> Co-authored-by: ofekshenawa <[email protected]>
1 parent 1a7d2f4 commit e8ad794

28 files changed

+42
-85
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ testdeps: testdata/redis/src/redis-server
1919
bench: testdeps
2020
go test ./... -test.run=NONE -test.bench=. -test.benchmem
2121

22-
.PHONY: all test testdeps bench
22+
.PHONY: all test testdeps bench fmt
2323

2424
testdata/redis:
2525
mkdir -p $@
@@ -29,7 +29,7 @@ testdata/redis/src/redis-server: testdata/redis
2929
cd $< && make all
3030

3131
fmt:
32-
gofmt -w -s ./
32+
gofumpt -w ./
3333
goimports -w -local github.com/redis/go-redis ./
3434

3535
go_mod_tidy:

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ go get github.com/redis/go-redis/v9
6969
```go
7070
import (
7171
"context"
72-
"github.com/redis/go-redis/v9"
7372
"fmt"
73+
74+
"github.com/redis/go-redis/v9"
7475
)
7576

7677
var ctx = context.Background()
@@ -125,8 +126,9 @@ go-redis also supports connecting via the [redis uri specification](https://gith
125126
```go
126127
import (
127128
"context"
128-
"github.com/redis/go-redis/v9"
129129
"fmt"
130+
131+
"github.com/redis/go-redis/v9"
130132
)
131133

132134
var ctx = context.Background()

cluster_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
. "github.com/bsm/ginkgo/v2"
1515
. "github.com/bsm/gomega"
16+
1617
"github.com/redis/go-redis/v9"
1718
"github.com/redis/go-redis/v9/internal/hashtag"
1819
)
@@ -1457,7 +1458,7 @@ var _ = Describe("ClusterClient timeout", func() {
14571458
})
14581459

14591460
var _ = Describe("ClusterClient ParseURL", func() {
1460-
var cases = []struct {
1461+
cases := []struct {
14611462
test string
14621463
url string
14631464
o *redis.ClusterOptions // expected value

command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4324,7 +4324,6 @@ func (cmd *FunctionStatsCmd) readDuration(rd *proto.Reader) (time.Duration, erro
43244324
}
43254325

43264326
func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) {
4327-
43284327
n, err := rd.ReadArrayLen()
43294328
if err != nil {
43304329
return nil, err
@@ -4341,6 +4340,7 @@ func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) {
43414340

43424341
return command, nil
43434342
}
4343+
43444344
func (cmd *FunctionStatsCmd) readRunningScripts(rd *proto.Reader) ([]RunningScript, bool, error) {
43454345
n, err := rd.ReadArrayLen()
43464346
if err != nil {

commands.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ func (info LibraryInfo) Validate() error {
609609

610610
// Hello Set the resp protocol used.
611611
func (c statefulCmdable) Hello(ctx context.Context,
612-
ver int, username, password, clientName string) *MapStringInterfaceCmd {
612+
ver int, username, password, clientName string,
613+
) *MapStringInterfaceCmd {
613614
args := make([]interface{}, 0, 7)
614615
args = append(args, "hello", ver)
615616
if password != "" {

commands_test.go

+4-19
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ var _ = Describe("Commands", func() {
232232
})
233233

234234
It("should ClientSetInfo", func() {
235-
236235
pipe := client.Pipeline()
237236

238237
// Test setting the libName
@@ -413,7 +412,6 @@ var _ = Describe("Commands", func() {
413412
})
414413

415414
It("should filter commands by ACL category", func() {
416-
417415
filter := &redis.FilterBy{
418416
ACLCat: "admin",
419417
}
@@ -580,7 +578,6 @@ var _ = Describe("Commands", func() {
580578
n, err = client.Exists(ctx, "key").Result()
581579
Expect(err).NotTo(HaveOccurred())
582580
Expect(n).To(Equal(int64(0)))
583-
584581
})
585582

586583
It("should Keys", func() {
@@ -727,7 +724,6 @@ var _ = Describe("Commands", func() {
727724
})
728725

729726
It("should PExpireTime", func() {
730-
731727
// The command returns -1 if the key exists but has no associated expiration time.
732728
// The command returns -2 if the key does not exist.
733729
pExpireTime := client.PExpireTime(ctx, "key")
@@ -966,7 +962,6 @@ var _ = Describe("Commands", func() {
966962
})
967963

968964
It("should ExpireTime", func() {
969-
970965
// The command returns -1 if the key exists but has no associated expiration time.
971966
// The command returns -2 if the key does not exist.
972967
expireTimeCmd := client.ExpireTime(ctx, "key")
@@ -988,7 +983,6 @@ var _ = Describe("Commands", func() {
988983
})
989984

990985
It("should TTL", func() {
991-
992986
// The command returns -1 if the key exists but has no associated expire
993987
// The command returns -2 if the key does not exist.
994988
ttl := client.TTL(ctx, "key")
@@ -2042,7 +2036,6 @@ var _ = Describe("Commands", func() {
20422036
})
20432037

20442038
It("should ACL LOG", func() {
2045-
20462039
err := client.Do(ctx, "acl", "setuser", "test", ">test", "on", "allkeys", "+get").Err()
20472040
Expect(err).NotTo(HaveOccurred())
20482041

@@ -2073,7 +2066,6 @@ var _ = Describe("Commands", func() {
20732066
limitedLogEntries, err := client.ACLLog(ctx, 2).Result()
20742067
Expect(err).NotTo(HaveOccurred())
20752068
Expect(len(limitedLogEntries)).To(Equal(2))
2076-
20772069
})
20782070

20792071
It("should ACL LOG RESET", func() {
@@ -2087,7 +2079,6 @@ var _ = Describe("Commands", func() {
20872079
Expect(err).NotTo(HaveOccurred())
20882080
Expect(len(logEntries)).To(Equal(0))
20892081
})
2090-
20912082
})
20922083

20932084
Describe("hashes", func() {
@@ -2699,7 +2690,6 @@ var _ = Describe("Commands", func() {
26992690
Expect(err).NotTo(HaveOccurred())
27002691
Expect(key).To(Equal("list2"))
27012692
Expect(val).To(Equal([]string{"a", "b", "c", "d"}))
2702-
27032693
})
27042694

27052695
It("should BLMPopBlocks", func() {
@@ -2721,15 +2711,15 @@ var _ = Describe("Commands", func() {
27212711
case <-done:
27222712
Fail("BLMPop is not blocked")
27232713
case <-time.After(time.Second):
2724-
//ok
2714+
// ok
27252715
}
27262716

27272717
_, err := client.LPush(ctx, "list_list", "a").Result()
27282718
Expect(err).NotTo(HaveOccurred())
27292719

27302720
select {
27312721
case <-done:
2732-
//ok
2722+
// ok
27332723
case <-time.After(time.Second):
27342724
Fail("BLMPop is still blocked")
27352725
}
@@ -4184,7 +4174,6 @@ var _ = Describe("Commands", func() {
41844174
})
41854175

41864176
It("should ZMPop", func() {
4187-
41884177
err := client.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "one"}).Err()
41894178
Expect(err).NotTo(HaveOccurred())
41904179
err = client.ZAdd(ctx, "zset", redis.Z{Score: 2, Member: "two"}).Err()
@@ -4256,11 +4245,9 @@ var _ = Describe("Commands", func() {
42564245
Score: 6,
42574246
Member: "six",
42584247
}}))
4259-
42604248
})
42614249

42624250
It("should BZMPop", func() {
4263-
42644251
err := client.ZAdd(ctx, "zset", redis.Z{Score: 1, Member: "one"}).Err()
42654252
Expect(err).NotTo(HaveOccurred())
42664253
err = client.ZAdd(ctx, "zset", redis.Z{Score: 2, Member: "two"}).Err()
@@ -4360,15 +4347,15 @@ var _ = Describe("Commands", func() {
43604347
case <-done:
43614348
Fail("BZMPop is not blocked")
43624349
case <-time.After(time.Second):
4363-
//ok
4350+
// ok
43644351
}
43654352

43664353
err := client.ZAdd(ctx, "list_list", redis.Z{Score: 1, Member: "one"}).Err()
43674354
Expect(err).NotTo(HaveOccurred())
43684355

43694356
select {
43704357
case <-done:
4371-
//ok
4358+
// ok
43724359
case <-time.After(time.Second):
43734360
Fail("BZMPop is still blocked")
43744361
}
@@ -6928,7 +6915,6 @@ var _ = Describe("Commands", func() {
69286915

69296916
close(started)
69306917
})
6931-
69326918
})
69336919

69346920
Describe("SlowLogGet", func() {
@@ -6949,7 +6935,6 @@ var _ = Describe("Commands", func() {
69496935
Expect(len(result)).NotTo(BeZero())
69506936
})
69516937
})
6952-
69536938
})
69546939

69556940
type numberStruct struct {

doctests/lpush_lrange_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ package example_commands_test
55
import (
66
"context"
77
"fmt"
8+
89
"github.com/redis/go-redis/v9"
910
)
1011

11-
func ExampleLPushLRange() {
12+
func ExampleClient_LPush_and_lrange() {
1213
ctx := context.Background()
1314

1415
rdb := redis.NewClient(&redis.Options{

doctests/set_get_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ package example_commands_test
55
import (
66
"context"
77
"fmt"
8+
89
"github.com/redis/go-redis/v9"
910
)
1011

11-
func ExampleSetGet() {
12+
func ExampleClient_Set_and_get() {
1213
ctx := context.Background()
1314

1415
rdb := redis.NewClient(&redis.Options{

example/del-keys-without-ttl/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import (
66
"sync"
77
"time"
88

9-
"github.com/redis/go-redis/v9"
109
"go.uber.org/zap"
10+
11+
"github.com/redis/go-redis/v9"
1112
)
1213

1314
func main() {

extra/redisotel/metrics.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
"net"
77
"time"
88

9-
"github.com/redis/go-redis/v9"
109
"go.opentelemetry.io/otel"
1110
"go.opentelemetry.io/otel/attribute"
1211
"go.opentelemetry.io/otel/metric"
12+
13+
"github.com/redis/go-redis/v9"
1314
)
1415

1516
// InstrumentMetrics starts reporting OpenTelemetry Metrics.

extra/redisprometheus/collector.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ var _ prometheus.Collector = (*Collector)(nil)
2929
// The given namespace and subsystem are used to build the fully qualified metric name,
3030
// i.e. "{namespace}_{subsystem}_{metric}".
3131
// The provided metrics are:
32-
// * pool_hit_total
33-
// * pool_miss_total
34-
// * pool_timeout_total
35-
// * pool_conn_total_current
36-
// * pool_conn_idle_current
37-
// * pool_conn_stale_total
32+
// - pool_hit_total
33+
// - pool_miss_total
34+
// - pool_timeout_total
35+
// - pool_conn_total_current
36+
// - pool_conn_idle_current
37+
// - pool_conn_stale_total
3838
func NewCollector(namespace, subsystem string, getter StatGetter) *Collector {
3939
return &Collector{
4040
getter: getter,

internal/customvet/checks/setval/setval.go

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"go/ast"
55
"go/token"
66
"go/types"
7+
78
"golang.org/x/tools/go/analysis"
89
)
910

internal/customvet/checks/setval/setval_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package setval_test
33
import (
44
"testing"
55

6-
"github.com/redis/go-redis/internal/customvet/checks/setval"
76
"golang.org/x/tools/go/analysis/analysistest"
7+
8+
"github.com/redis/go-redis/internal/customvet/checks/setval"
89
)
910

1011
func Test(t *testing.T) {

internal/customvet/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package main
22

33
import (
4-
"github.com/redis/go-redis/internal/customvet/checks/setval"
54
"golang.org/x/tools/go/analysis/multichecker"
5+
6+
"github.com/redis/go-redis/internal/customvet/checks/setval"
67
)
78

89
func main() {

internal/pool/conn_check.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
2-
// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
32

43
package pool
54

internal/pool/conn_check_dummy.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos
2-
// +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos
32

43
package pool
54

internal/pool/conn_check_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
2-
// +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
32

43
package pool
54

internal/util/safe.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build appengine
2-
// +build appengine
32

43
package util
54

internal/util/unsafe.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !appengine
2-
// +build !appengine
32

43
package util
54

main_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ const (
3636
sentinelPort3 = "9128"
3737
)
3838

39-
var redisPort = "6380"
40-
var redisAddr = ":" + redisPort
39+
var (
40+
redisPort = "6380"
41+
redisAddr = ":" + redisPort
42+
)
4143

4244
var (
4345
sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3}

options_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build go1.7
2-
// +build go1.7
32

43
package redis
54

probabilistic.go

+1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ func NewBFInfoCmd(ctx context.Context, args ...interface{}) *BFInfoCmd {
310310
func (cmd *BFInfoCmd) SetVal(val BFInfo) {
311311
cmd.val = val
312312
}
313+
313314
func (cmd *BFInfoCmd) String() string {
314315
return cmdString(cmd, cmd.val)
315316
}

0 commit comments

Comments
 (0)