Skip to content

Commit 4334ccb

Browse files
chore(deps): update dependency golangci/golangci-lint to v2.4.0 (#108)
* chore(deps): update dependency golangci/golangci-lint to v2.4.0 * chore(deps): update dependency golangci/golangci-lint to v2 * fix: lint errors * fix: lint errors --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: DrPsychick <drpsychick@drsick.net>
1 parent 5a81f9f commit 4334ccb

File tree

12 files changed

+227
-75
lines changed

12 files changed

+227
-75
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
name: Lint code
1212
runs-on: ubuntu-latest
1313
env:
14-
GOLANGCI_LINT_VERSION: v2.1.6 # github-releases:golangci/golangci-lint
14+
GOLANGCI_LINT_VERSION: v2.4.0 # github-releases:golangci/golangci-lint
1515
steps:
16-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1717
- name: Set up Go
1818
uses: actions/setup-go@v5
1919
with:

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ linters:
2020
- varnamelen
2121
- wrapcheck
2222
- wsl
23+
- noinlineerr
2324
settings:
2425
cyclop:
2526
max-complexity: 12

application.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func GetLocaleWithFallback(registry l10n.LocaleRegistry, locale string) (l10n.Lo
3939
}
4040
}
4141
}
42+
4243
return loc, Response{}
4344
}
4445

@@ -51,9 +52,12 @@ type ResponseError interface {
5152

5253
// HandleError handles default and ResponseErrors. Returns true if the error was handled.
5354
func HandleError(b *ResponseBuilder, loc l10n.LocaleInstance, err error) bool {
54-
var resp Response
55-
var respErr ResponseError
56-
var l10nErr l10n.LocaleError
55+
var (
56+
resp Response
57+
respErr ResponseError
58+
l10nErr l10n.LocaleError
59+
)
60+
5761
switch {
5862
case loc == nil:
5963
resp = Response{
@@ -89,6 +93,7 @@ func HandleError(b *ResponseBuilder, loc l10n.LocaleInstance, err error) bool {
8993
// }
9094

9195
b.With(resp)
96+
9297
return true
9398
}
9499

@@ -99,11 +104,13 @@ func CheckForLocaleError(loc l10n.LocaleInstance) error {
99104
return nil
100105
}
101106

102-
lastErr := errs[len(errs)-1] //nolint:ifshort,nolintlint
107+
lastErr := errs[len(errs)-1] //nolint:nolintlint
108+
103109
var l10nErr l10n.LocaleError
104110
if errors.As(lastErr, &l10nErr) {
105111
return TranslationError{l10nErr.GetLocale(), l10nErr.GetKey()}
106112
}
113+
107114
return TextError{loc.GetName(), lastErr.Error()}
108115
}
109116

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ require (
1818
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
1919
github.com/modern-go/reflect2 v1.0.2 // indirect
2020
github.com/pmezard/go-difflib v1.0.0 // indirect
21-
github.com/puzpuzpuz/xsync v1.5.2 // indirect
2221
github.com/valyala/fastrand v1.1.0 // indirect
2322
go.opentelemetry.io/otel v1.34.0 // indirect
2423
go.opentelemetry.io/otel/trace v1.34.0 // indirect

go.sum

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,56 @@
1-
github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI=
2-
github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
3-
github.com/aws/aws-lambda-go v1.48.0 h1:1aZUYsrJu0yo5fC4z+Rba1KhNImXcJcvHu763BxoyIo=
4-
github.com/aws/aws-lambda-go v1.48.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
51
github.com/aws/aws-lambda-go v1.49.0 h1:z4VhTqkFZPM3xpEtTqWqRqsRH4TZBMJqTkRiBPYLqIQ=
62
github.com/aws/aws-lambda-go v1.49.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
73
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
84
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
9-
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
10-
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
5+
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
6+
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
117
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
128
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
139
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1410
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
1511
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
16-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
17-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
1812
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1913
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
2014
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
21-
github.com/hamba/logger/v2 v2.5.1 h1:EM+S6CPYIs66XmW9kK/RBghgtkLcO4kQWWPAlsIwNR4=
22-
github.com/hamba/logger/v2 v2.5.1/go.mod h1:b+y7XddZMTTSIjKdOOIHWlhg1hMoE9eKhanB9wPNLj0=
23-
github.com/hamba/logger/v2 v2.6.0 h1:73CPbhY5luRzITKeX8hhdL4K3jezsH8cyTYgcOl7JeA=
24-
github.com/hamba/logger/v2 v2.6.0/go.mod h1:JEikfAmI6C/vaSE8MSb4SXTgWclNSN6tmdyyLv3/ATA=
25-
github.com/hamba/logger/v2 v2.7.0 h1:CnDL1tpSlQ7OjdPlRBf2ZXSmouqsY2hWOK0Dy2oRabM=
26-
github.com/hamba/logger/v2 v2.7.0/go.mod h1:0WAKwMox/SJ7b0dP7jZMx8S9sVXAaOU1deWQzB2lFeg=
2715
github.com/hamba/logger/v2 v2.8.0 h1:0JJnEhVW4sHGn4/9fPP0LsZXD2ytG+NrnrXCdM8/vmg=
2816
github.com/hamba/logger/v2 v2.8.0/go.mod h1:V58KZPAmDEWi14dOZjbKDPFkdyvpGwxXtLzLkVTNBic=
29-
github.com/hamba/statter/v2 v2.3.4 h1:g8rJIlDhN9s1Td5x+g+uvgbI0HmTzLiZoRmCfLK8CAI=
30-
github.com/hamba/statter/v2 v2.3.4/go.mod h1:bBparxhvlgp5rWvmaGIc6+Tc4kOYF6cUU0bDUjjaioA=
31-
github.com/hamba/statter/v2 v2.3.5 h1:qAFu+n4Q08LtrBdcBYexItfOoJJ16D/m/boq8fm5hn4=
32-
github.com/hamba/statter/v2 v2.3.5/go.mod h1:LS7DqETxoVpRraL3tn9O70zYCaVRL2A98SvZw/LZkAI=
33-
github.com/hamba/statter/v2 v2.4.0 h1:0axag+o3oFGH7UC+tYXN3oY/Qq5pspQUaMpHjtxjw40=
34-
github.com/hamba/statter/v2 v2.4.0/go.mod h1:U8ojLXmTKsBQ8HX+JVW3iqOw2Wepm4YnTYoxyim6spA=
35-
github.com/hamba/statter/v2 v2.6.0 h1:d64DL4p48xAW4M876jrtguuEFXFf6cDFJR0WxNCDKVI=
36-
github.com/hamba/statter/v2 v2.6.0/go.mod h1:5QpB06ilNfJNfXW5YYe4cHUlh1NGTjIlpKDv/nl7U8w=
37-
github.com/hamba/statter/v2 v2.6.1 h1:AVNKPEyRz3y4tpzkW4a7eHcdpjUOvyEtH0eqSRQl/uY=
38-
github.com/hamba/statter/v2 v2.6.1/go.mod h1:r3rbO7/TeKsPpL5iFMOKqSD6PzLptg+w6TPHccBNeaQ=
3917
github.com/hamba/statter/v2 v2.7.0 h1:9CnjJ5PcxOzIVJSAFSJm0lnUUBjTo3psV9nn+yZ1cMM=
4018
github.com/hamba/statter/v2 v2.7.0/go.mod h1:SJPj0HCM+z7GxnoG+YBgN87SP0GVJ5YPjqHINrgqFYE=
4119
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
4220
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
43-
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
44-
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
4521
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
4622
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
4723
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
4824
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
4925
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
26+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
27+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
5028
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
5129
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
52-
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
53-
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
54-
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
55-
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
56-
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
57-
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
58-
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
59-
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
60-
github.com/puzpuzpuz/xsync v1.5.2 h1:yRAP4wqSOZG+/4pxJ08fPTwrfL0IzE/LKQ/cw509qGY=
61-
github.com/puzpuzpuz/xsync v1.5.2/go.mod h1:K98BYhX3k1dQ2M63t1YNVDanbwUPmBCAhNmVrrxfiGg=
30+
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
31+
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
32+
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
33+
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
34+
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
35+
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
36+
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
37+
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
6238
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6339
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
6440
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
6541
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
66-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
67-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
68-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
69-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
70-
github.com/stretchr/testify v1.11.0 h1:ib4sjIrwZKxE5u/Japgo/7SJV3PvgjGiRNAvTVGqQl8=
71-
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
7242
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
7343
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
7444
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
7545
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
76-
go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y=
77-
go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI=
78-
go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY=
79-
go.opentelemetry.io/otel v1.23.1/go.mod h1:Td0134eafDLcTS4y+zQ26GE8u3dEuRBiBCTUIRHaikA=
80-
go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs=
81-
go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4=
82-
go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts=
83-
go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc=
8446
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
8547
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
86-
go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0=
87-
go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo=
88-
go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6HmYY8=
89-
go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI=
90-
go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA=
91-
go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0=
92-
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
93-
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
9448
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
9549
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
96-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
97-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
98-
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
99-
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
50+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
51+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
52+
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
53+
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
10054
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
10155
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10256
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

l10n/l10n.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (e MissingPlaceholderError) Error() string {
134134
if e.Placeholder == "" {
135135
return fmt.Sprintf("locale %s: key '%s' is missing a placeholder in translation", e.Locale, e.Key)
136136
}
137+
137138
return fmt.Sprintf("locale %s: key '%s' is missing placeholder '%s' in translation", e.Locale, e.Key, e.Placeholder)
138139
}
139140

@@ -217,6 +218,7 @@ func (r *Registry) Register(l LocaleInstance, opts ...RegisterFunc) error {
217218
if l.GetName() == "" {
218219
return errors.New("cannot register locale with no name")
219220
}
221+
220222
if _, ok := r.locales[l.GetName()]; ok {
221223
return fmt.Errorf("locale %s already registered", l.GetName())
222224
}
@@ -247,7 +249,9 @@ func (r *Registry) SetDefault(locale string) error {
247249
if _, err := r.Resolve(locale); err != nil {
248250
return err
249251
}
252+
250253
r.defaultLocale = locale
254+
251255
return nil
252256
}
253257

@@ -262,6 +266,7 @@ func (r *Registry) Resolve(locale string) (LocaleInstance, error) {
262266
if !ok {
263267
return nil, fmt.Errorf("locale '%s' not found", locale)
264268
}
269+
265270
return l, nil
266271
}
267272

@@ -303,7 +308,9 @@ func (l *Locale) Get(key string, args ...interface{}) string {
303308
l.errors = append(l.errors, err)
304309
}
305310
}
311+
306312
l.appendErrorMissingParam(key, []string{t})
313+
307314
return t
308315
}
309316

@@ -320,7 +327,9 @@ func (l *Locale) GetAny(key string, args ...interface{}) string {
320327
l.errors = append(l.errors, err)
321328
}
322329
}
330+
323331
l.appendErrorMissingParam(key, []string{t})
332+
324333
return t
325334
}
326335

@@ -337,7 +346,9 @@ func (l *Locale) GetAll(key string, args ...interface{}) []string {
337346
l.errors = append(l.errors, err)
338347
}
339348
}
349+
340350
l.appendErrorMissingParam(key, t)
351+
341352
return t
342353
}
343354

@@ -369,6 +380,7 @@ func (s Snippets) GetFirst(key string, args ...interface{}) (string, error) {
369380
if !ok || len(s[key]) == 0 {
370381
return "", NoTranslationError{"", key, ""}
371382
}
383+
372384
return fmt.Sprintf(s[key][0], args...), nil
373385
}
374386

@@ -378,11 +390,14 @@ func (s Snippets) GetAny(key string, args ...interface{}) (string, error) {
378390
if !ok || len(s[key]) == 0 {
379391
return "", NoTranslationError{"", key, ""}
380392
}
393+
381394
if len(s[key]) == 1 {
382395
return fmt.Sprintf(s[key][0], args...), nil
383396
}
397+
384398
l := len(s[key])
385399
r := rand.Intn(l) //nolint:gosec
400+
386401
return fmt.Sprintf(s[key][r], args...), nil
387402
}
388403

@@ -392,9 +407,11 @@ func (s Snippets) GetAll(key string, args ...interface{}) ([]string, error) {
392407
if !ok || len(s[key]) == 0 {
393408
return []string{}, NoTranslationError{"", key, ""}
394409
}
410+
395411
r := make([]string, len(s[key]))
396412
for i, v := range s[key] {
397413
r[i] = fmt.Sprintf(v, args...)
398414
}
415+
399416
return r, nil
400417
}

request.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func (e NotFoundError) Error() string {
1616
if e.name == "" {
1717
return fmt.Sprintf("element '%s' was not found in the request", e.element)
1818
}
19+
1920
return fmt.Sprintf("element '%s' with name '%s' was not found in the request", e.element, e.name)
2021
}
2122

@@ -116,6 +117,7 @@ func (r *RequestEnvelope) IntentName() string {
116117
if err != nil {
117118
return ""
118119
}
120+
119121
return i.Name
120122
}
121123

@@ -273,6 +275,7 @@ func (r *RequestEnvelope) RequestType() RequestType {
273275
if r.Request == nil {
274276
return ""
275277
}
278+
276279
return r.Request.Type
277280
}
278281

@@ -281,6 +284,7 @@ func (r *RequestEnvelope) IsIntentRequest() bool {
281284
if r.Request == nil || r.Request.Type == "" {
282285
return false
283286
}
287+
284288
return r.Request.Type == TypeIntentRequest
285289
}
286290

@@ -289,6 +293,7 @@ func (r *RequestEnvelope) RequestLocale() string {
289293
if r.Request == nil {
290294
return ""
291295
}
296+
292297
return string(r.Request.Locale)
293298
}
294299

@@ -377,6 +382,7 @@ func (r *RequestEnvelope) SessionID() string {
377382
if r.Session == nil {
378383
return ""
379384
}
385+
380386
return r.Session.SessionID
381387
}
382388

@@ -385,6 +391,7 @@ func (r *RequestEnvelope) SessionUser() (*ContextUser, error) {
385391
if r.Session == nil || r.Session.User == nil {
386392
return nil, &NotFoundError{"Session.User", ""}
387393
}
394+
388395
return r.Session.User, nil
389396
}
390397

@@ -433,6 +440,7 @@ func (r *RequestEnvelope) ContextPerson() (*ContextSystemPerson, error) {
433440
if err != nil || s.Person == nil {
434441
return &ContextSystemPerson{}, &NotFoundError{"System.Person", ""}
435442
}
443+
436444
return r.Context.System.Person, nil
437445
}
438446

@@ -442,6 +450,7 @@ func (r *RequestEnvelope) ContextUser() (*ContextUser, error) {
442450
if err != nil || s.User == nil {
443451
return &ContextUser{}, &NotFoundError{"System.User", ""}
444452
}
453+
445454
return r.Context.System.User, nil
446455
}
447456

0 commit comments

Comments
 (0)