Skip to content

Commit f080543

Browse files
committed
go: upgrade to Go 1.26.4 and run go fix ./...
1 parent cdc8b78 commit f080543

20 files changed

Lines changed: 108 additions & 89 deletions

File tree

.drone.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ name: checkup
66

77
steps:
88
- name: test-mysql
9-
image: golang:1.14
9+
image: golang:1.26.4
1010
pull: always
1111
commands:
1212
- make test-mysql
1313
- make build-mysql
1414

1515
- name: test-postgres
16-
image: golang:1.14
16+
image: golang:1.26.4
1717
pull: always
1818
commands:
1919
- make test-postgres
2020
- make build-postgres
2121

2222
- name: test-sqlite3
23-
image: golang:1.14
23+
image: golang:1.26.4
2424
pull: always
2525
commands:
2626
- make test-sqlite3

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: go
22

33
go:
4-
- 1.14
4+
- 1.26.4

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.14-alpine as builder
1+
FROM golang:1.26.4-alpine as builder
22

33
ENV CGO_ENABLED=0
44

check/exec/exec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
func TestChecker(t *testing.T) {
8-
assert := func(ok bool, format string, args ...interface{}) {
8+
assert := func(ok bool, format string, args ...any) {
99
if !ok {
1010
t.Errorf(format, args...)
1111
}

check/http/http.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package http
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
6+
"io"
7+
78
"net"
89
"net/http"
910
"strings"
@@ -199,7 +200,7 @@ func (c Checker) checkDown(resp *http.Response) error {
199200
if c.MustContain == "" && c.MustNotContain == "" {
200201
return nil
201202
}
202-
bodyBytes, err := ioutil.ReadAll(resp.Body)
203+
bodyBytes, err := io.ReadAll(resp.Body)
203204
if err != nil {
204205
return fmt.Errorf("reading response body: %w", err)
205206
}

check/tcp/tcp.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"io/ioutil"
9+
"os"
10+
1011
"net"
1112
"time"
1213

@@ -109,7 +110,7 @@ func (c Checker) doChecks() types.Attempts {
109110
var tlsConfig tls.Config
110111
tlsConfig.InsecureSkipVerify = c.TLSSkipVerify
111112
if c.TLSCAFile != "" {
112-
rootPEM, err := ioutil.ReadFile(c.TLSCAFile)
113+
rootPEM, err := os.ReadFile(c.TLSCAFile)
113114
if err != nil || rootPEM == nil {
114115
return nil, errReadingRootCert
115116
}

check/tls/tls.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import (
55
"crypto/x509"
66
"encoding/json"
77
"fmt"
8-
"io/ioutil"
8+
"os"
9+
910
"net"
1011
"time"
1112

@@ -18,11 +19,11 @@ const Type = "tls"
1819
// Checker implements a Checker for TLS endpoints.
1920
//
2021
// TODO: Implement more checks on the certificate and TLS configuration.
21-
// - Cipher suites
22-
// - Protocol versions
23-
// - OCSP stapling
24-
// - Multiple SNIs
25-
// - Other things that you might see at SSL Labs or other TLS health checks
22+
// - Cipher suites
23+
// - Protocol versions
24+
// - OCSP stapling
25+
// - Multiple SNIs
26+
// - Other things that you might see at SSL Labs or other TLS health checks
2627
type Checker struct {
2728
// Name is the name of the endpoint.
2829
Name string `json:"endpoint_name"`
@@ -92,7 +93,7 @@ func (c Checker) Check() (types.Result, error) {
9293
c.tlsConfig.RootCAs = x509.NewCertPool()
9394
}
9495
for _, fname := range c.TrustedRoots {
95-
pemData, err := ioutil.ReadFile(fname)
96+
pemData, err := os.ReadFile(fname)
9697
if err != nil {
9798
return types.Result{}, fmt.Errorf("error loading file: %w", err)
9899
}

check/tls/tls_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestChecker(t *testing.T) {
130130

131131
func makeSelfSignedCert(hostname, keyType string, validity time.Duration) (tls.Certificate, error) {
132132
// start by generating private key
133-
var privKey interface{}
133+
var privKey any
134134
var err error
135135
switch keyType {
136136
case "", "ec256":
@@ -168,7 +168,7 @@ func makeSelfSignedCert(hostname, keyType string, validity time.Duration) (tls.C
168168
}
169169
cert.DNSNames = append(cert.DNSNames, hostname)
170170

171-
publicKey := func(privKey interface{}) interface{} {
171+
publicKey := func(privKey any) any {
172172
switch k := privKey.(type) {
173173
case *rsa.PrivateKey:
174174
return &k.PublicKey

checkup.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Checkup struct {
3030
// Useful if wanting to perform distributed check
3131
// "at the same time" even if they might actually
3232
// be a few milliseconds or seconds apart.
33-
Timestamp time.Time `json:"timestamp,omitempty"`
33+
Timestamp time.Time `json:"timestamp"`
3434

3535
// Storage is the storage mechanism for saving the
3636
// results of checks. Required if calling Store().
@@ -148,7 +148,7 @@ func (c Checkup) MarshalJSON() ([]byte, error) {
148148
// handling; unfortunately this has to mimic c's definition.
149149
easy := struct {
150150
ConcurrentChecks int `json:"concurrent_checks,omitempty"`
151-
Timestamp time.Time `json:"timestamp,omitempty"`
151+
Timestamp time.Time `json:"timestamp"`
152152
}{
153153
ConcurrentChecks: c.ConcurrentChecks,
154154
Timestamp: c.Timestamp,
@@ -175,7 +175,7 @@ func (c Checkup) MarshalJSON() ([]byte, error) {
175175
if err != nil {
176176
return result, err
177177
}
178-
chb = []byte(fmt.Sprintf(`{"type":"%s",%s`, ch.Type(), string(chb[1:])))
178+
chb = fmt.Appendf(nil, `{"type":"%s",%s`, ch.Type(), string(chb[1:]))
179179
checkers = append(checkers, chb)
180180
}
181181

@@ -192,7 +192,7 @@ func (c Checkup) MarshalJSON() ([]byte, error) {
192192
if err != nil {
193193
return result, err
194194
}
195-
sb = []byte(fmt.Sprintf(`{"type":"%s",%s`, c.Storage.Type(), string(sb[1:])))
195+
sb = fmt.Appendf(nil, `{"type":"%s",%s`, c.Storage.Type(), string(sb[1:]))
196196
wrap("storage", sb)
197197
}
198198

@@ -205,7 +205,7 @@ func (c Checkup) MarshalJSON() ([]byte, error) {
205205
return result, err
206206
}
207207

208-
chb = []byte(fmt.Sprintf(`{"type":"%s",%s`, ch.Type(), string(chb[1:])))
208+
chb = fmt.Appendf(nil, `{"type":"%s",%s`, ch.Type(), string(chb[1:]))
209209
checkers = append(checkers, chb)
210210
}
211211

checkup_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package checkup
33
import (
44
"bytes"
55
"errors"
6-
"io/ioutil"
6+
"os"
7+
78
"sync"
89
"testing"
910
"time"
@@ -182,7 +183,7 @@ func TestJSON(t *testing.T) {
182183
testConfig = "testdata/config.json"
183184
)
184185

185-
jsonBytes, err := ioutil.ReadFile(testConfig)
186+
jsonBytes, err := os.ReadFile(testConfig)
186187
if err != nil {
187188
t.Fatalf("Error reading config file: %s", testConfig)
188189
}

0 commit comments

Comments
 (0)