Skip to content

Commit bfd090e

Browse files
authored
Merge pull request #65 from gojekfarm/simplify-go-versions
Update Go version to 1.25 across multiple modules and workflows; adjust GitHub Actions configuration for Go setup
2 parents 9b9b0d9 + 920b733 commit bfd090e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+232
-188
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,31 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x]
1512
steps:
1613
- name: Install Go
1714
uses: actions/setup-go@v2
1815
with:
19-
go-version: ${{ matrix.go-version }}
16+
go-version: 1.25.x
2017
- name: Checkout code
2118
uses: actions/checkout@v2
2219
- name: Go mod cache
2320
uses: actions/cache@v4
2421
with:
2522
path: ~/go/pkg/mod
26-
key: ${{ runner.os }}-go${{ matrix.go-version }}
23+
key: ${{ runner.os }}-go1.25.x
2724
- name: Tools bin cache
2825
uses: actions/cache@v4
2926
with:
3027
path: .bin
31-
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('Makefile') }}
28+
key: ${{ runner.os }}-go1.25.x-${{ hashFiles('Makefile') }}
29+
- name: Check
30+
run: make check
3231
- name: Test
33-
run: make ci
32+
run: make test
33+
- name: Coverage
34+
run: make test-cov
35+
- name: Generate coverage report in XML format
36+
run: make test-xml
3437
- name: Upload coverage to Codecov
3538
uses: codecov/codecov-action@v2
3639
with:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ tools/vendor
4646
go.work
4747
go.work.sum
4848

49-
.envrc
49+
.envrc
50+
.claude/

.golangci.yml

Lines changed: 103 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,123 @@
1+
version: "2"
2+
13
linters:
2-
disable-all: true
4+
default: none
5+
# This list of linters is not a recommendation (same thing for all this configuration file).
6+
# We intentionally use a limited set of linters.
37
enable:
4-
- errcheck
5-
- staticcheck
6-
- unused
7-
- gosimple
8-
- ineffassign
9-
- stylecheck
10-
- typecheck
11-
- unconvert
128
- bodyclose
9+
- copyloopvar
10+
- dogsled
1311
- dupl
12+
- errcheck
13+
- errorlint
14+
- funlen
15+
- gocheckcompilerdirectives
16+
- gochecknoinits
1417
- goconst
18+
- gocritic
1519
- gocyclo
16-
- gofmt
20+
- godox
21+
- mnd
22+
- goprintffuncname
23+
- gosec
24+
- govet
25+
- intrange
26+
- ineffassign
1727
- lll
1828
- misspell
1929
- nakedret
20-
- exportloopref
21-
- funlen
22-
- nestif
23-
- nlreturn
24-
- prealloc
25-
- rowserrcheck
30+
- noctx
31+
- nolintlint
32+
- revive
33+
- staticcheck
34+
- testifylint
2635
- unconvert
2736
- unparam
37+
- unused
2838
- whitespace
29-
- wsl
39+
40+
settings:
41+
govet:
42+
enable-all: true
43+
settings:
44+
shadow:
45+
strict: true
46+
errcheck:
47+
check-type-assertions: true
48+
misspell:
49+
locale: UK
50+
ignore-words:
51+
- initialized
52+
funlen:
53+
lines: 80
54+
statements: 40
55+
gci:
56+
sections:
57+
- standard
58+
- default
59+
- blank
60+
- dot
61+
- alias
62+
custom-order: true
63+
revive:
64+
rules:
65+
- name: package-comments
66+
disabled: true
67+
exclusions:
68+
generated: lax
69+
rules:
70+
- path: _test\.go
71+
linters:
72+
- dupl
73+
- gosec
74+
- wsl
75+
- lll
76+
- funlen
77+
- nlreturn
78+
- unused
79+
- path: _test\.go
80+
text: "^Error return value is not checked$"
81+
linters:
82+
- errcheck
83+
- text: "^SA1019:.* is deprecated:"
84+
linters:
85+
- staticcheck
86+
- text: "declaration of \"(err|ctx)\" shadows declaration at"
87+
linters:
88+
- govet
89+
- text: "return value of `tx.Rollback` is not checked"
90+
linters:
91+
- errcheck
92+
93+
formatters:
94+
enable:
95+
- gofmt
96+
- gci
97+
98+
settings:
99+
gofmt:
100+
simplify: true
101+
rewrite-rules:
102+
- pattern: 'interface{}'
103+
replacement: 'any'
104+
- pattern: 'a[b:len(a)]'
105+
replacement: 'a[b:]'
106+
gci:
107+
sections:
108+
- standard
109+
- default
110+
- blank
111+
- dot
112+
- prefix(github.com/gojekfarm)
113+
custom-order: true
114+
30115
run:
31116
skip-dirs:
32117
- bin
33118
skip-files:
34119
- .*mock.*\.go$
35120
- version.go
36-
- .*\_test\.go$
121+
- .*_test\.go$
37122
- generate.go
38123
modules-download-mode: readonly
39-
linters-settings:
40-
govet:
41-
check-shadowing: true
42-
enable-all: true
43-
disable:
44-
- asmdecl
45-
- assign
46-
errcheck:
47-
check-type-assertions: true
48-
misspell:
49-
locale: UK
50-
ignore-words:
51-
- initialized
52-
funlen:
53-
lines: 80
54-
statements: 40
55-
56-
issues:
57-
exclude-use-default: false
58-
exclude:
59-
- declaration of "(err|ctx)" shadows declaration at
60-
exclude-rules:
61-
- text: "^SA1019: .* is deprecated:"
62-
linters:
63-
- staticcheck
64-
- path: _test\.go
65-
linters:
66-
- dupl
67-
- gosec
68-
- wsl
69-
- lll
70-
- funlen
71-
- nlreturn
72-
- unused
73-
- path: _test\.go
74-
text: ^Error return value is not checked$
75-
linters:
76-
- errcheck

Makefile

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,35 @@
11
ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
2-
# extract go minor version from go version output
3-
GO_MINOR_VERSION := $(shell go version | cut -d' ' -f3 | cut -d'.' -f2)
42

53
EXCLUDE_DIRS := ./examples
64
EXCLUDE_GO_MOD_DIRS := $(shell find $(EXCLUDE_DIRS) -type f -name 'go.mod' -exec dirname {} \; | sort)
75

8-
# set build directory based on go minor version
9-
GO_BUILD_DIRS := $(foreach dir,$(ALL_GO_MOD_DIRS),$(shell GO_MOD_VERSION=$$(grep "go 1.[0-9]*" $(dir)/go.mod | cut -d' ' -f2 | cut -d'.' -f2) && [ -n "$$GO_MOD_VERSION" ] && [ $(GO_MINOR_VERSION) -ge $$GO_MOD_VERSION ] && echo $(dir)))
6+
GO_BUILD_DIRS := $(ALL_GO_MOD_DIRS)
107

118
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
129
BIN_DIR := $(PROJECT_DIR)/.bin
1310

14-
fmt:
15-
@$(call run-go-mod-dir,go fmt ./...,"go fmt")
16-
17-
gofmt:
18-
@$(call run-go-mod-dir,go fmt ./...,"gofmt -s -w")
11+
fmt: golangci-lint
12+
@$(call run-go-mod-dir,$(GOLANGCI_LINT) fmt,".bin/golangci-lint fmt")
1913

2014
vet:
2115
@$(call run-go-mod-dir,go vet ./...,"go vet")
2216

2317
lint: golangci-lint
24-
@$(call run-go-mod-dir,$(GOLANGCI_LINT) run --timeout=10m -v,".bin/golangci-lint")
25-
26-
.PHONY: ci
27-
ci: test test-cov test-xml
18+
$(GOLANGCI_LINT) run --timeout=10m -v
2819

29-
imports: gci
30-
@$(call run-go-mod-dir,$(GCI) -w -local github.com/gojekfarm ./ | { grep -v -e 'skip file .*' || true; },".bin/gci")
3120

32-
.PHONY: gomod.tidy
33-
gomod.tidy:
21+
.PHONY: tidy
22+
tidy:
3423
@$(call run-go-mod-dir,go mod tidy,"go mod tidy")
3524

36-
.PHONY: go.generate
37-
go.generate: mockery protoc
25+
.PHONY: generate
26+
generate: mockery protoc
3827
@$(call run-go-mod-dir,go generate ./...,"go generate")
3928

4029
## test: Run all tests
4130
.PHONY: test test-run test-cov test-xml
4231

43-
test: check test-run
44-
45-
test-run:
32+
test:
4633
@$(call run-go-mod-dir,go test -race -covermode=atomic -coverprofile=coverage.out ./...,"go test")
4734

4835
test-cov: gocov
@@ -59,28 +46,14 @@ test-html: test-cov gocov-html
5946
@open coverage.html
6047

6148
.PHONY: check
62-
check: fmt vet imports lint
49+
check: fmt vet lint
6350
@git diff --quiet || test $$(git diff --name-only | grep -v -e 'go.mod$$' -e 'go.sum$$' | wc -l) -eq 0 || ( echo "The following changes (result of code generators and code checks) have been detected:" && git --no-pager diff && false ) # fail if Git working tree is dirty
6451

6552
# ========= Helpers ===========
6653

67-
## Determine the golangci-lint version based on $(GO_MINOR_VERSION)
68-
###################
69-
GOLANGCI_LINT_V18 := v1.50.1
70-
GOLANGCI_LINT_DEFAULT := v1.53.3
71-
72-
get-golangci-lint-version = $(or $(value GOLANGCI_LINT_V$(1)), $(GOLANGCI_LINT_DEFAULT))
73-
GOLANGCI_LINT_VERSION := $(call get-golangci-lint-version,$(GO_MINOR_VERSION))
74-
75-
###################
76-
7754
GOLANGCI_LINT = $(BIN_DIR)/golangci-lint
7855
golangci-lint:
79-
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))
80-
81-
GCI = $(BIN_DIR)/gci
82-
gci:
83-
$(call go-get-tool,$(GCI),github.com/daixiang0/[email protected])
56+
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest)
8457

8558
GOCOV = $(BIN_DIR)/gocov
8659
gocov:

errors/go.mod

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

3-
go 1.21
3+
go 1.25
44

55
require github.com/stretchr/testify v1.10.0
66

examples/xkafka/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/gojekfarm/xtools/examples/xkafka
22

3-
go 1.21
3+
go 1.25
44

55
replace (
66
github.com/gojekfarm/xtools => ../../

examples/xload/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/gojekfarm/xtools/examples/xload
22

3-
go 1.20
3+
go 1.25
44

55
replace (
66
github.com/gojekfarm/xtools/xload => ../../xload

examples/xload/go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
5+
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
56
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
7+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
68
github.com/gotidy/ptr v1.4.0 h1:7++suUs+HNHMnyz6/AW3SE+4EnBhupPSQTSI7QNijVc=
9+
github.com/gotidy/ptr v1.4.0/go.mod h1:MjRBG6/IETiiZGWI8LrRtISXEji+8b/jigmj2q0mEyM=
710
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
11+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
812
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
13+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
914
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1015
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1116
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
17+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
1218
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
1319
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
1420
github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
1521
github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
1622
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1723
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
1824
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
25+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
1926
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
2027
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
2128
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
2229
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
2330
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2431
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
32+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2533
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2634
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

examples/xload/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func main() {
8787
_ = f.Close()
8888
}
8989

90-
func prettyPrint(v interface{}) {
90+
func prettyPrint(v any) {
9191
out, _ := json.MarshalIndent(v, "", " ")
9292
println(string(out))
9393
}

generic/go.mod

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

3-
go 1.18
3+
go 1.25
44

55
require github.com/stretchr/testify v1.7.0
66

0 commit comments

Comments
 (0)