Skip to content

Commit c9bf80e

Browse files
authored
Merge pull request #87 from cryptopay-dev/B2B-6196-Bump-go-version-to-1.21
[B2B-6196] Bump Go version to 1.21
2 parents 8a94e02 + 9d3cdb6 commit c9bf80e

File tree

11 files changed

+35
-30
lines changed

11 files changed

+35
-30
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ jobs:
55
lint:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2
8+
- uses: actions/checkout@v4
99
- name: Run golangci-lint
1010
uses: reviewdog/action-golangci-lint@v1
1111
with:
1212
github_token: ${{ secrets.github_token }}
1313
test:
1414
runs-on: ubuntu-latest
15-
container: golang:1.14-alpine
15+
container: golang:1.21-alpine3.18
1616
services:
1717
redis:
1818
image: redis
1919
steps:
2020
- name: Install common dependencies
2121
run: apk add --no-cache gcc libc-dev
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323
- run: go test -v ./...
2424
env:
2525
REDIS_ADDR: redis:6379

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.PHONY:test
22
test:
3-
go test -v ./...
3+
go test -v ./...
4+
5+
.PHONY: lint
6+
lint:
7+
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:latest golangci-lint run -v

clients/pg.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,22 @@ import (
99
"github.com/spf13/viper"
1010
)
1111

12-
type dbQueryHook struct {
13-
logger *logrus.Entry
14-
}
12+
type (
13+
dbQueryHook struct {
14+
logger *logrus.Entry
15+
}
16+
17+
ctxKey int
18+
)
19+
20+
const ctxRequestStartKey ctxKey = 1 + iota
1521

1622
func (d dbQueryHook) BeforeQuery(ctx context.Context, event *pg.QueryEvent) (context.Context, error) {
17-
return context.WithValue(ctx, "start_time", time.Now()), nil
23+
return context.WithValue(ctx, ctxRequestStartKey, time.Now()), nil
1824
}
1925

2026
func (d dbQueryHook) AfterQuery(ctx context.Context, event *pg.QueryEvent) error {
21-
st, ok := ctx.Value("start_time").(time.Time)
27+
st, ok := ctx.Value(ctxRequestStartKey).(time.Time)
2228
if !ok {
2329
return nil
2430
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/cryptopay-dev/narada
22

3-
go 1.17
3+
go 1.21
44

55
require (
66
github.com/bsm/redislock v0.7.1

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ github.com/bsm/gomega v1.13.0/go.mod h1:JifAceMQ4crZIWYUKrlGcmbN3bqHogVTADMD2ATs
7575
github.com/bsm/redislock v0.7.1 h1:nBMm91MRuGOOSlHZNEF0+HpiaH1i8QpSALrF/q7b/Es=
7676
github.com/bsm/redislock v0.7.1/go.mod h1:TSF3xUotaocycoHjVAp535/bET+ZmvrtcyNrXc0Whm8=
7777
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
78-
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
7978
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
8079
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
8180
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
@@ -98,7 +97,6 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
9897
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
9998
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
10099
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
101-
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
102100
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
103101
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
104102
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
@@ -411,7 +409,6 @@ github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
411409
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
412410
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
413411
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
414-
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
415412
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
416413
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
417414
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

lock/redis_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313
var redisAddr = os.Getenv("REDIS_ADDR")
1414

1515
func TestNewRedisLocker(t *testing.T) {
16+
if testing.Short() {
17+
t.Skip("skipping test in short mode")
18+
}
19+
1620
cfg := viper.New()
1721
cfg.Set("redis.addr", redisAddr)
1822
redis, err := clients.NewRedis(cfg)

logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package narada
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"io"
66

77
"github.com/sirupsen/logrus"
88
"github.com/spf13/viper"
@@ -52,7 +52,7 @@ func NewLogger(config *viper.Viper) (*logrus.Logger, error) {
5252

5353
func NewNopLogger() *logrus.Logger {
5454
logger := logrus.New()
55-
logger.Out = ioutil.Discard
55+
logger.Out = io.Discard
5656

5757
return logger
5858
}

logger_hooks_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package narada
22

33
import (
44
"errors"
5-
"io/ioutil"
5+
"io"
66
"testing"
77
"time"
88

@@ -53,12 +53,6 @@ func TestNewLogrusSlackHook(t *testing.T) {
5353
})
5454

5555
t.Run("Sending message to Slack", func(t *testing.T) {
56-
//hwe, err := ioutil.ReadFile("./fixtures/slack/hook_with_error.json")
57-
//assert.NoError(t, err)
58-
59-
//hwm, err := ioutil.ReadFile("./fixtures/slack/hook_with_message.json")
60-
//assert.NoError(t, err)
61-
6256
t.Run("With error attached", func(t *testing.T) {
6357
defer gock.Off()
6458
done := make(chan bool, 1)
@@ -83,7 +77,7 @@ func TestNewLogrusSlackHook(t *testing.T) {
8377
cfg.Set("app.name", "default")
8478

8579
logger := logrus.New()
86-
logger.Out = ioutil.Discard
80+
logger.Out = io.Discard
8781

8882
hook := NewLogrusSlackHook(cfg)
8983
logger.AddHook(hook)
@@ -121,7 +115,7 @@ func TestNewLogrusSlackHook(t *testing.T) {
121115
cfg.Set("app.name", "default")
122116

123117
logger := logrus.New()
124-
logger.Out = ioutil.Discard
118+
logger.Out = io.Discard
125119

126120
hook := NewLogrusSlackHook(cfg)
127121
logger.AddHook(hook)

slack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"time"
1010
)
@@ -70,7 +70,7 @@ func (c *SlackClient) SendMessage(msg *SlackMessage) error {
7070
defer resp.Body.Close()
7171

7272
if resp.StatusCode != 200 {
73-
t, _ := ioutil.ReadAll(resp.Body)
73+
t, _ := io.ReadAll(resp.Body)
7474
return &SlackError{resp.StatusCode, string(t)}
7575
}
7676

slack_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package narada
22

33
import (
4-
"io/ioutil"
4+
"os"
55
"testing"
66

77
"github.com/stretchr/testify/assert"
@@ -12,7 +12,7 @@ func TestNewClient(t *testing.T) {
1212
gock.Clean()
1313

1414
// Reading fixture
15-
buf, err := ioutil.ReadFile("./fixtures/slack/request.json")
15+
buf, err := os.ReadFile("./fixtures/slack/request.json")
1616
assert.NoError(t, err)
1717

1818
t.Run("Errors", func(t *testing.T) {

0 commit comments

Comments
 (0)