Skip to content

Commit 10b5083

Browse files
authored
fix: Bump from go 1.18 to 1.23 (#22)
1 parent 77f653d commit 10b5083

34 files changed

+166
-169
lines changed

.github/workflows/go-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
strategy:
1212
matrix:
1313
go:
14-
- version: '1.18'
14+
- version: '1.23'
1515
run_lint: 'false'
16-
- version: '1.19'
16+
- version: '1.24'
1717
run_lint: 'true'
1818

1919
name: Go Test (Linux)

.golangci.yml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,49 @@
1+
version: "2"
12
run:
2-
deadline: 120s
33
tests: false
4-
54
linters:
65
enable:
76
- bodyclose
8-
- deadcode
9-
- depguard
107
- dupl
11-
- errcheck
12-
- goconst
138
- gochecknoglobals
149
- gochecknoinits
1510
- goconst
1611
- gocritic
1712
- gocyclo
1813
- godox
19-
- gofmt
20-
- goimports
2114
- gosec
22-
- gosimple
23-
- govet
24-
- ineffassign
2515
- lll
26-
- megacheck
2716
- misspell
2817
- nakedret
2918
- nolintlint
3019
- prealloc
3120
- revive
3221
- staticcheck
33-
- stylecheck
34-
- typecheck
3522
- unconvert
3623
- unparam
37-
- unused
38-
- varcheck
3924
- whitespace
40-
fast: false
41-
42-
linters-settings:
43-
gofmt:
44-
simplify: false
45-
goimports:
46-
local-prefixes: gopkg.in/launchdarkly,github.com/launchdarkly
47-
25+
exclusions:
26+
generated: lax
27+
paths:
28+
- third_party$
29+
- builtin$
30+
- examples$
4831
issues:
49-
exclude-use-default: false
5032
max-same-issues: 1000
51-
max-per-linter: 1000
33+
formatters:
34+
enable:
35+
- gofmt
36+
- goimports
37+
settings:
38+
gofmt:
39+
simplify: false
40+
goimports:
41+
local-prefixes:
42+
- gopkg.in/launchdarkly
43+
- github.com/launchdarkly
44+
exclusions:
45+
generated: lax
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$

.ldrelease/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22

33
jobs:
44
- docker:
5-
image: golang:1.18-buster
5+
image: golang:1.23-buster
66
template:
77
name: go
88

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
GOLANGCI_LINT_VERSION=v1.48.0
1+
GOLANGCI_LINT_VERSION=v1.64.5
32

43
LINTER=./bin/golangci-lint
54
LINTER_VERSION_FILE=./bin/.golangci-lint-version-$(GOLANGCI_LINT_VERSION)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This project centralizes some test support code that is used by LaunchDarkly's G
66

77
While this code may be useful in other projects, it is primarily geared toward LaunchDarkly's own development needs and is not meant to provide a large general-purpose framework. It is meant for unit test code and should not be used as a runtime dependency.
88

9-
This version of the project requires Go 1.18 or higher.
9+
This version of the project requires Go 1.23 or higher.
1010

1111
## Contents
1212

files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ func WithTempDir(f func(path string)) {
5757
if err != nil {
5858
panic(err)
5959
}
60-
defer os.RemoveAll(path) //nolint:errcheck
60+
defer os.RemoveAll(path)
6161
f(path)
6262
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/launchdarkly/go-test-helpers/v3
22

3-
go 1.18
3+
go 1.23
44

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

httphelpers/certificates.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func WithSelfSignedServer(handler http.Handler, action func(*httptest.Server, []
4949
if err != nil {
5050
panic(fmt.Errorf("can't create self-signed certificate: %s", err))
5151
}
52-
certData, err := os.ReadFile(certFilePath) //nolint:gosec
52+
certData, err := os.ReadFile(certFilePath)
5353
if err != nil {
5454
panic(fmt.Errorf("can't read self-signed certificate: %s", err))
5555
}
@@ -132,7 +132,7 @@ func MakeSelfSignedCert(certFilePath, keyFilePath string) error {
132132
return err
133133
}
134134

135-
certOut, err := os.Create(certFilePath) //nolint:gosec
135+
certOut, err := os.Create(certFilePath)
136136
if err != nil {
137137
return err
138138
}
@@ -143,7 +143,7 @@ func MakeSelfSignedCert(certFilePath, keyFilePath string) error {
143143
return err
144144
}
145145

146-
keyOut, err := os.OpenFile(keyFilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) //nolint:gosec
146+
keyOut, err := os.OpenFile(keyFilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
147147
if err != nil {
148148
return err
149149
}
@@ -160,7 +160,7 @@ func MakeSelfSignedCert(certFilePath, keyFilePath string) error {
160160
return nil
161161
}
162162

163-
func pemBlockForKey(priv interface{}) (*pem.Block, error) {
163+
func pemBlockForKey(priv any) (*pem.Block, error) {
164164
switch k := priv.(type) {
165165
case *rsa.PrivateKey:
166166
return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)}, nil
@@ -175,7 +175,7 @@ func pemBlockForKey(priv interface{}) (*pem.Block, error) {
175175
}
176176
}
177177

178-
func publicKey(priv interface{}) interface{} {
178+
func publicKey(priv any) any {
179179
switch k := priv.(type) {
180180
case *rsa.PrivateKey:
181181
return &k.PublicKey

httphelpers/handlers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ func HandlerForPathRegex(pathRegex string, handlerForPath http.Handler, defaultH
8888

8989
// HandlerWithJSONResponse creates an HTTP handler that returns a 200 status and the JSON encoding of
9090
// the specified object.
91-
func HandlerWithJSONResponse(contentToEncode interface{}, additionalHeaders http.Header) http.Handler {
92-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
91+
func HandlerWithJSONResponse(contentToEncode any, additionalHeaders http.Header) http.Handler {
92+
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
9393
bytes, err := json.Marshal(contentToEncode)
9494
if err != nil {
9595
log.Printf("error encoding JSON response: %s", err)
@@ -107,7 +107,7 @@ func HandlerWithJSONResponse(contentToEncode interface{}, additionalHeaders http
107107

108108
// HandlerWithResponse creates an HTTP handler that always returns the same status code, headers, and body.
109109
func HandlerWithResponse(status int, headers http.Header, body []byte) http.Handler {
110-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
110+
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
111111
for k, vv := range headers {
112112
w.Header()[k] = vv
113113
}
@@ -120,7 +120,7 @@ func HandlerWithResponse(status int, headers http.Header, body []byte) http.Hand
120120

121121
// HandlerWithStatus creates an HTTP handler that always returns the same status code.
122122
func HandlerWithStatus(status int) http.Handler {
123-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
123+
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
124124
w.WriteHeader(status)
125125
})
126126
}
@@ -174,7 +174,7 @@ func SequentialHandler(firstHandler http.Handler, remainingHandlers ...http.Hand
174174
// client := NewClientFromHandler(handler)
175175
// // All requests made with this client will return an error
176176
func BrokenConnectionHandler() http.Handler {
177-
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
177+
return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
178178
if _, ok := w.(*httptest.ResponseRecorder); ok {
179179
panic("httphelpers.BrokenConnectionHandler cannot be used with a ResponseRecorder")
180180
}

httphelpers/handlers_streaming.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (s *chunkedStreamingHandlerImpl) removeChannel(channelToRemove chan []byte)
157157
// This is called when the client closed the connection.
158158
go func() {
159159
// Consume anything else that gets sent on this channel, until it's closed, to avoid deadlock
160-
for range channelToRemove {
160+
for range channelToRemove { //nolint:revive // Intentionally draining the channel
161161
}
162162
}()
163163

@@ -176,7 +176,7 @@ func (s *chunkedStreamingHandlerImpl) removeChannel(channelToRemove chan []byte)
176176
close(channelToRemove)
177177
}
178178

179-
func (s *chunkedStreamingHandlerImpl) ServeHTTP(w http.ResponseWriter, r *http.Request) {
179+
func (s *chunkedStreamingHandlerImpl) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
180180
flusher, ok := w.(http.Flusher)
181181
if !ok {
182182
log.Println("httphelpers.ChunkedStreamingHandler can't be used with a ResponseWriter that does not support Flush")

0 commit comments

Comments
 (0)