Skip to content

Commit

Permalink
Update to Go 1.23, fix govet errors (#5853)
Browse files Browse the repository at this point in the history
This PR:

1. Updates the nightly and Travis configs to Go 1.23 (using Go 1.22 as
the old version)
2. Bumps the minimum version in `go.mod` to Go 1.22
3. Fixes a number of new `govet` warnings around non-constant format
strings

Signed-off-by: Neil Twigg <[email protected]>
  • Loading branch information
derekcollison authored Sep 3, 2024
2 parents fb4c102 + f6556da commit 5761fcf
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: ./src/github.com/nats-io/nats-server/.github/actions/nightly-release
with:
go: "1.21"
go: "1.23"
workdir: src/github.com/nats-io/nats-server
label: nightly
hub_username: "${{ secrets.DOCKER_USERNAME }}"
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ language: go
go:
# This should be quoted or use .x, but should not be unquoted.
# Remember that a YAML bare float drops trailing zeroes.
- "1.23.0"
- "1.22.6"
- "1.21.13"

go_import_path: github.com/nats-io/nats-server

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
- name: "Run all tests from all other packages"
env: TEST_SUITE=non_srv_pkg_tests
- name: "Compile with older Go release"
go: "1.21.x"
go: "1.22.x"
env: TEST_SUITE=build_only

script: ./scripts/runTestsOnTravis.sh $TEST_SUITE
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nats-io/nats-server/v2

go 1.21.0
go 1.22.0

require (
github.com/google/go-tpm v0.9.0
Expand Down
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,11 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
2 changes: 1 addition & 1 deletion scripts/runTestsOnTravis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ "$1" = "compile" ]; then
go build;

# Now run the linters.
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1;
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3;
golangci-lint run;
if [ "$TRAVIS_TAG" != "" ]; then
go test -race -v -run=TestVersionMatchesTag ./server -ldflags="-X=github.com/nats-io/nats-server/v2/server.serverVersion=$TRAVIS_TAG" -count=1 -vet=off
Expand Down
6 changes: 3 additions & 3 deletions server/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

func TestErrCtx(t *testing.T) {
ctx := "Extra context information"
e := NewErrorCtx(ErrWrongGateway, ctx)
e := NewErrorCtx(ErrWrongGateway, "%s", ctx)

if e.Error() != ErrWrongGateway.Error() {
t.Fatalf("%v and %v are supposed to be identical", e, ErrWrongGateway)
Expand All @@ -45,9 +45,9 @@ func TestErrCtx(t *testing.T) {

func TestErrCtxWrapped(t *testing.T) {
ctxO := "Original Ctx"
eO := NewErrorCtx(ErrWrongGateway, ctxO)
eO := NewErrorCtx(ErrWrongGateway, "%s", ctxO)
ctx := "Extra context information"
e := NewErrorCtx(eO, ctx)
e := NewErrorCtx(eO, "%s", ctx)

if e.Error() != ErrWrongGateway.Error() {
t.Fatalf("%v and %v are supposed to be identical", e, ErrWrongGateway)
Expand Down
6 changes: 3 additions & 3 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7825,7 +7825,7 @@ func (mset *stream) processClusteredInboundMsg(subject, reply string, hdr, msg [
// Check msgSize if we have a limit set there. Again this works if it goes through but better to be pre-emptive.
if maxMsgSize >= 0 && (len(hdr)+len(msg)) > maxMsgSize {
err := fmt.Errorf("JetStream message size exceeds limits for '%s > %s'", jsa.acc().Name, mset.cfg.Name)
s.RateLimitWarnf(err.Error())
s.RateLimitWarnf("%s", err.Error())
if canRespond {
var resp = &JSPubAckResponse{PubAck: &PubAck{Stream: name}}
resp.Error = NewJSStreamMessageExceedsMaximumError()
Expand All @@ -7842,7 +7842,7 @@ func (mset *stream) processClusteredInboundMsg(subject, reply string, hdr, msg [
// Again this works if it goes through but better to be pre-emptive.
if len(hdr) > math.MaxUint16 {
err := fmt.Errorf("JetStream header size exceeds limits for '%s > %s'", jsa.acc().Name, mset.cfg.Name)
s.RateLimitWarnf(err.Error())
s.RateLimitWarnf("%s", err.Error())
if canRespond {
var resp = &JSPubAckResponse{PubAck: &PubAck{Stream: name}}
resp.Error = NewJSStreamHeaderExceedsMaximumError()
Expand Down Expand Up @@ -7991,7 +7991,7 @@ func (mset *stream) processClusteredInboundMsg(subject, reply string, hdr, msg [
// TODO(dlc) - Make this a limit where we drop messages to protect ourselves, but allow to be configured.
if mset.clseq-(lseq+mset.clfs) > streamLagWarnThreshold {
lerr := fmt.Errorf("JetStream stream '%s > %s' has high message lag", jsa.acc().Name, name)
s.RateLimitWarnf(lerr.Error())
s.RateLimitWarnf("%s", lerr.Error())
}
mset.clMu.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion server/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4333,7 +4333,7 @@ func TestRouteSlowConsumerRecover(t *testing.T) {

go func() {
var total int
payload := fmt.Appendf(nil, strings.Repeat("A", 132*1024))
payload := bytes.Repeat([]byte("A"), 132*1024)
for range time.NewTicker(30 * time.Millisecond).C {
select {
case <-ctx.Done():
Expand Down
6 changes: 3 additions & 3 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2052,11 +2052,11 @@ func TestServerRateLimitLogging(t *testing.T) {
// Wait for more than the expiration interval
time.Sleep(200 * time.Millisecond)
if c1 == nil {
s.RateLimitWarnf(nb1)
s.RateLimitWarnf("%s", nb1)
s.rateLimitFormatWarnf("warning value %d", 1)
} else {
c1.RateLimitWarnf(nb1)
c2.RateLimitWarnf(nb1)
c1.RateLimitWarnf("%s", nb1)
c2.RateLimitWarnf("%s", nb1)
c1.rateLimitFormatWarnf("warning value %d", 1)
}
gotOne = 0
Expand Down

0 comments on commit 5761fcf

Please sign in to comment.