diff --git a/Makefile b/Makefile index b16709c8..2733cfa0 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,6 @@ testdata/redis: testdata/redis/src/redis-server: testdata/redis cd $< && make all -tag: - git tag $(VERSION) - git tag extra/rediscmd/$(VERSION) - git tag extra/redisotel/$(VERSION) - git tag extra/rediscensus/$(VERSION) +fmt: + gofmt -w -s ./ + goimports -w -local github.com/go-redis/redis ./ diff --git a/cluster_test.go b/cluster_test.go index 3880d437..6ee7364e 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -9,11 +9,11 @@ import ( "sync" "time" - "github.com/go-redis/redis/v8" - "github.com/go-redis/redis/v8/internal/hashtag" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" + "github.com/go-redis/redis/v8/internal/hashtag" ) type clusterScenario struct { diff --git a/command_test.go b/command_test.go index d110d0c3..168f9f69 100644 --- a/command_test.go +++ b/command_test.go @@ -4,10 +4,10 @@ import ( "errors" "time" - redis "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + redis "github.com/go-redis/redis/v8" ) var _ = Describe("Cmd", func() { @@ -72,7 +72,7 @@ var _ = Describe("Cmd", func() { }) It("supports time.Time", func() { - tm := time.Date(2019, 01, 01, 9, 45, 10, 222125, time.UTC) + tm := time.Date(2019, 1, 1, 9, 45, 10, 222125, time.UTC) err := client.Set(ctx, "time_key", tm, 0).Err() Expect(err).NotTo(HaveOccurred()) diff --git a/commands_test.go b/commands_test.go index a331f7f9..985744cb 100644 --- a/commands_test.go +++ b/commands_test.go @@ -472,11 +472,11 @@ var _ = Describe("Commands", func() { idleTime := client.ObjectIdleTime(ctx, "key") Expect(idleTime.Err()).NotTo(HaveOccurred()) - //Redis returned milliseconds/1000, which may cause ObjectIdleTime to be at a critical value, - //should be +1s to deal with the critical value problem. - //if too much time (>1s) is used during command execution, it may also cause the test to fail. - //so the ObjectIdleTime result should be <=now-start+1s - //link: https://github.com/redis/redis/blob/5b48d900498c85bbf4772c1d466c214439888115/src/object.c#L1265-L1272 + // Redis returned milliseconds/1000, which may cause ObjectIdleTime to be at a critical value, + // should be +1s to deal with the critical value problem. + // if too much time (>1s) is used during command execution, it may also cause the test to fail. + // so the ObjectIdleTime result should be <=now-start+1s + // link: https://github.com/redis/redis/blob/5b48d900498c85bbf4772c1d466c214439888115/src/object.c#L1265-L1272 Expect(idleTime.Val()).To(BeNumerically("<=", time.Now().Sub(start)+time.Second)) }) diff --git a/example/otel/main.go b/example/otel/main.go index 9bb272eb..d92f51d2 100644 --- a/example/otel/main.go +++ b/example/otel/main.go @@ -4,12 +4,13 @@ import ( "context" "sync" - "github.com/go-redis/redis/extra/redisotel/v8" - "github.com/go-redis/redis/v8" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" sdktrace "go.opentelemetry.io/otel/sdk/trace" + + "github.com/go-redis/redis/extra/redisotel/v8" + "github.com/go-redis/redis/v8" ) var tracer = otel.Tracer("redisexample") diff --git a/example/scan-struct/main.go b/example/scan-struct/main.go index c2f036e1..aee7ef71 100644 --- a/example/scan-struct/main.go +++ b/example/scan-struct/main.go @@ -4,6 +4,7 @@ import ( "context" "github.com/davecgh/go-spew/spew" + "github.com/go-redis/redis/v8" ) diff --git a/extra/rediscensus/rediscensus.go b/extra/rediscensus/rediscensus.go index 1ea6a57c..9af094e9 100644 --- a/extra/rediscensus/rediscensus.go +++ b/extra/rediscensus/rediscensus.go @@ -3,9 +3,10 @@ package rediscensus import ( "context" + "go.opencensus.io/trace" + "github.com/go-redis/redis/extra/rediscmd/v8" "github.com/go-redis/redis/v8" - "go.opencensus.io/trace" ) type TracingHook struct{} diff --git a/extra/rediscmd/safe.go b/extra/rediscmd/safe.go index efe92f6e..6d3a8b7a 100644 --- a/extra/rediscmd/safe.go +++ b/extra/rediscmd/safe.go @@ -1,3 +1,4 @@ +//go:build appengine // +build appengine package rediscmd diff --git a/extra/rediscmd/unsafe.go b/extra/rediscmd/unsafe.go index a90a48b7..7ccdf2fe 100644 --- a/extra/rediscmd/unsafe.go +++ b/extra/rediscmd/unsafe.go @@ -1,3 +1,4 @@ +//go:build !appengine // +build !appengine package rediscmd diff --git a/extra/redisotel/redisotel.go b/extra/redisotel/redisotel.go index 3da61130..89fa9722 100644 --- a/extra/redisotel/redisotel.go +++ b/extra/redisotel/redisotel.go @@ -3,12 +3,13 @@ package redisotel import ( "context" - "github.com/go-redis/redis/extra/rediscmd/v8" - "github.com/go-redis/redis/v8" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" + + "github.com/go-redis/redis/extra/rediscmd/v8" + "github.com/go-redis/redis/v8" ) var tracer = otel.Tracer("github.com/go-redis/redis") diff --git a/fuzz/fuzz.go b/fuzz/fuzz.go index c8497404..3225d245 100644 --- a/fuzz/fuzz.go +++ b/fuzz/fuzz.go @@ -1,11 +1,13 @@ +//go:build gofuzz // +build gofuzz package fuzz import ( "context" - "github.com/go-redis/redis/v8" "time" + + "github.com/go-redis/redis/v8" ) var ( diff --git a/go.mod b/go.mod index 68529135..8e752915 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( github.com/cespare/xxhash/v2 v2.1.2 + github.com/daixiang0/gci v0.2.9 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f github.com/google/go-cmp v0.5.6 // indirect github.com/onsi/ginkgo v1.16.4 diff --git a/go.sum b/go.sum index d9aec343..123c5e18 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/daixiang0/gci v0.2.9 h1:iwJvwQpBZmMg31w+QQ6jsyZ54KEATn6/nfARbBNW294= +github.com/daixiang0/gci v0.2.9/go.mod h1:+4dZ7TISfSmqfAGv59ePaHfNzgGtIkHAhhdKggP1JAc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -73,6 +75,7 @@ golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/hashtag/hashtag_test.go b/internal/hashtag/hashtag_test.go index 879e7bfe..c0b6396f 100644 --- a/internal/hashtag/hashtag_test.go +++ b/internal/hashtag/hashtag_test.go @@ -3,10 +3,10 @@ package hashtag import ( "testing" - "github.com/go-redis/redis/v8/internal/rand" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8/internal/rand" ) func TestGinkgoSuite(t *testing.T) { diff --git a/internal/hscan/hscan_test.go b/internal/hscan/hscan_test.go index 1f78bc7e..ab4c0e1d 100644 --- a/internal/hscan/hscan_test.go +++ b/internal/hscan/hscan_test.go @@ -69,7 +69,7 @@ var _ = Describe("Scan", func() { Expect(Scan(&d, i{v}, i{vals[k]})).To(HaveOccurred()) } - //success + // success f = func(v uint64) string { return strconv.FormatUint(v, 10) } diff --git a/internal/pool/pool_test.go b/internal/pool/pool_test.go index fcb12886..423a783c 100644 --- a/internal/pool/pool_test.go +++ b/internal/pool/pool_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "github.com/go-redis/redis/v8/internal/pool" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8/internal/pool" ) var _ = Describe("ConnPool", func() { diff --git a/internal/proto/scan_test.go b/internal/proto/scan_test.go index 5df3a6af..55df550b 100644 --- a/internal/proto/scan_test.go +++ b/internal/proto/scan_test.go @@ -3,9 +3,10 @@ package proto_test import ( "encoding/json" - "github.com/go-redis/redis/v8/internal/proto" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8/internal/proto" ) type testScanSliceStruct struct { diff --git a/internal/proto/writer_test.go b/internal/proto/writer_test.go index c5df9a6f..ebae5692 100644 --- a/internal/proto/writer_test.go +++ b/internal/proto/writer_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" - "github.com/go-redis/redis/v8/internal/proto" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8/internal/proto" ) type MyType struct{} @@ -51,7 +51,7 @@ var _ = Describe("WriteBuffer", func() { }) It("should append time", func() { - tm := time.Date(2019, 01, 01, 9, 45, 10, 222125, time.UTC) + tm := time.Date(2019, 1, 1, 9, 45, 10, 222125, time.UTC) err := wr.WriteArgs([]interface{}{tm}) Expect(err).NotTo(HaveOccurred()) diff --git a/internal/safe.go b/internal/safe.go index 862ff0eb..fd2f4340 100644 --- a/internal/safe.go +++ b/internal/safe.go @@ -1,3 +1,4 @@ +//go:build appengine // +build appengine package internal diff --git a/internal/unsafe.go b/internal/unsafe.go index 4bc79701..9f2e418f 100644 --- a/internal/unsafe.go +++ b/internal/unsafe.go @@ -1,3 +1,4 @@ +//go:build !appengine // +build !appengine package internal diff --git a/internal/util/safe.go b/internal/util/safe.go index 1b3060eb..21307110 100644 --- a/internal/util/safe.go +++ b/internal/util/safe.go @@ -1,3 +1,4 @@ +//go:build appengine // +build appengine package util diff --git a/internal/util/unsafe.go b/internal/util/unsafe.go index c9868aac..daa8d769 100644 --- a/internal/util/unsafe.go +++ b/internal/util/unsafe.go @@ -1,3 +1,4 @@ +//go:build !appengine // +build !appengine package util diff --git a/iterator_test.go b/iterator_test.go index 7a64f025..68c8b77e 100644 --- a/iterator_test.go +++ b/iterator_test.go @@ -3,10 +3,10 @@ package redis_test import ( "fmt" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("ScanIterator", func() { diff --git a/main_test.go b/main_test.go index 0cb2b1d4..5414310e 100644 --- a/main_test.go +++ b/main_test.go @@ -12,10 +12,10 @@ import ( "testing" "time" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) const ( @@ -295,7 +295,7 @@ func redisDir(port string) (string, error) { if err := os.RemoveAll(dir); err != nil { return "", err } - if err := os.MkdirAll(dir, 0775); err != nil { + if err := os.MkdirAll(dir, 0o775); err != nil { return "", err } return dir, nil diff --git a/options_test.go b/options_test.go index 9ffc6fca..6b5c4534 100644 --- a/options_test.go +++ b/options_test.go @@ -1,3 +1,4 @@ +//go:build go1.7 // +build go1.7 package redis diff --git a/pipeline_test.go b/pipeline_test.go index 9d2a60cf..f24114d7 100644 --- a/pipeline_test.go +++ b/pipeline_test.go @@ -3,10 +3,10 @@ package redis_test import ( "strconv" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("pipelining", func() { diff --git a/pool_test.go b/pool_test.go index 08acc6de..dbef72ec 100644 --- a/pool_test.go +++ b/pool_test.go @@ -4,10 +4,10 @@ import ( "context" "time" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("pool", func() { diff --git a/pubsub_test.go b/pubsub_test.go index 3e0bf9b0..2dfa66bd 100644 --- a/pubsub_test.go +++ b/pubsub_test.go @@ -7,10 +7,10 @@ import ( "sync" "time" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("PubSub", func() { diff --git a/race_test.go b/race_test.go index c9428d91..34699d13 100644 --- a/race_test.go +++ b/race_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("races", func() { diff --git a/redis_test.go b/redis_test.go index 9f189052..05c6d791 100644 --- a/redis_test.go +++ b/redis_test.go @@ -8,10 +8,10 @@ import ( "testing" "time" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) type redisHookError struct { diff --git a/ring.go b/ring.go index 5e35b6bb..11a20370 100644 --- a/ring.go +++ b/ring.go @@ -12,7 +12,8 @@ import ( "time" "github.com/cespare/xxhash/v2" - "github.com/dgryski/go-rendezvous" + rendezvous "github.com/dgryski/go-rendezvous" //nolint + "github.com/go-redis/redis/v8/internal" "github.com/go-redis/redis/v8/internal/hashtag" "github.com/go-redis/redis/v8/internal/pool" diff --git a/ring_test.go b/ring_test.go index 2189cd63..03a49fd7 100644 --- a/ring_test.go +++ b/ring_test.go @@ -9,10 +9,10 @@ import ( "sync" "time" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("Redis Ring", func() { @@ -190,8 +190,8 @@ var _ = Describe("Redis Ring", func() { Describe("Process hook", func() { BeforeEach(func() { - //the health check leads to data race for variable "stack []string". - //here, the health check time is set to 72 hours to avoid health check + // the health check leads to data race for variable "stack []string". + // here, the health check time is set to 72 hours to avoid health check opt := redisRingOptions() opt.HeartbeatFrequency = 72 * time.Hour ring = redis.NewRing(opt) diff --git a/sentinel_test.go b/sentinel_test.go index 7b4aabdb..754f33d7 100644 --- a/sentinel_test.go +++ b/sentinel_test.go @@ -3,10 +3,10 @@ package redis_test import ( "net" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("Sentinel", func() { diff --git a/tx_test.go b/tx_test.go index 4681122a..7deb2dfd 100644 --- a/tx_test.go +++ b/tx_test.go @@ -5,10 +5,10 @@ import ( "strconv" "sync" - "github.com/go-redis/redis/v8" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/go-redis/redis/v8" ) var _ = Describe("Tx", func() {