Skip to content

Commit 6df8886

Browse files
committed
fix(lint): please the linter
1 parent 9cca565 commit 6df8886

7 files changed

Lines changed: 35 additions & 47 deletions

File tree

cmd/http-check-server/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"os/signal"
88
"syscall"
99

10-
"github.com/pkg/errors"
11-
1210
"github.com/MauveSoftware/http-check/internal/api"
1311
"github.com/MauveSoftware/http-check/internal/server"
1412
"github.com/sirupsen/logrus"
@@ -18,7 +16,7 @@ import (
1816
)
1917

2018
const (
21-
version = "0.3.4"
19+
version = "0.3.5"
2220
)
2321

2422
var (
@@ -63,7 +61,7 @@ func openSocket() (net.Listener, error) {
6361
cleanupSocket()
6462
lis, err := net.Listen("unix", *socketPath)
6563
if err != nil {
66-
return nil, errors.Wrap(err, "Failed to listen on socket")
64+
return nil, fmt.Errorf("faild to listen on socket: %w", err)
6765
}
6866

6967
return lis, nil

cmd/http-check/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
const (
17-
version = "0.3.4"
17+
version = "0.3.5"
1818
)
1919

2020
var (

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.26
55
require (
66
github.com/alecthomas/kingpin/v2 v2.4.0
77
github.com/golang/protobuf v1.5.4
8-
github.com/pkg/errors v0.9.1
98
github.com/sirupsen/logrus v1.9.4
109
github.com/stretchr/testify v1.11.1
1110
google.golang.org/grpc v1.81.1
@@ -16,10 +15,10 @@ require (
1615
github.com/davecgh/go-spew v1.1.1 // indirect
1716
github.com/pmezard/go-difflib v1.0.0 // indirect
1817
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
19-
golang.org/x/net v0.54.0 // indirect
20-
golang.org/x/sys v0.44.0 // indirect
18+
golang.org/x/net v0.55.0 // indirect
19+
golang.org/x/sys v0.45.0 // indirect
2120
golang.org/x/text v0.37.0 // indirect
22-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260519071638-aa98bba5eb94 // indirect
21+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect
2322
google.golang.org/protobuf v1.36.11 // indirect
2423
gopkg.in/yaml.v3 v3.0.1 // indirect
2524
)

go.sum

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1717
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
1818
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
1919
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
20-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
21-
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
2220
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2321
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2422
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
@@ -47,26 +45,22 @@ go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfC
4745
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
4846
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
4947
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
50-
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
51-
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
5248
golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w=
5349
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
54-
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
55-
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
50+
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
51+
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
5652
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
5753
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
58-
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
59-
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
54+
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
55+
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
6056
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
6157
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
6258
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
6359
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
64-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 h1:pfIbyB44sWzHiCpRqIen67ZQnVXSfIxWrqUMk1qwODE=
65-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
6660
google.golang.org/genproto/googleapis/rpc v0.0.0-20260519071638-aa98bba5eb94 h1:eZCjr/aAF8c5ccm5pb6T4EXgIei5MlAAPWPJk+5ArfY=
6761
google.golang.org/genproto/googleapis/rpc v0.0.0-20260519071638-aa98bba5eb94/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
68-
google.golang.org/grpc v1.81.0 h1:W3G9N3KQf3BU+YuCtGKJk0CmxQNbAISICD/9AORxLIw=
69-
google.golang.org/grpc v1.81.0/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
62+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk=
63+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
7064
google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
7165
google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
7266
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=

internal/server/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ func (s *HTTPCheckServer) startWorkers() {
3636
for i := 0; i < int(s.workerCount); i++ {
3737
w := &worker{
3838
id: i + 1,
39-
cl: s.newHttpClient(false),
40-
insecureCl: s.newHttpClient(true),
39+
cl: s.newHTTPClient(false),
40+
insecureCl: s.newHTTPClient(true),
4141
ch: s.ch,
4242
}
4343
go w.run()
4444
}
4545
}
4646

47-
func (s *HTTPCheckServer) newHttpClient(insecure bool) *http.Client {
47+
func (s *HTTPCheckServer) newHTTPClient(insecure bool) *http.Client {
4848
var tr = &http.Transport{
4949
Dial: (&net.Dialer{
5050
Timeout: s.reqTimeout,

pkg/check/check.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ package check
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"net/http"
87
"regexp"
98
"strings"
109
"time"
11-
12-
"github.com/pkg/errors"
1310
)
1411

1512
// Option configures a check
@@ -62,7 +59,7 @@ func NewCheck(client *http.Client, url string, opts ...Option) *Check {
6259
func (c *Check) Run() error {
6360
req, err := http.NewRequest("GET", c.url, nil)
6461
if err != nil {
65-
return errors.Wrap(err, "Could not create request")
62+
return fmt.Errorf("could not create request: %w", err)
6663
}
6764

6865
req.SetBasicAuth(c.username, c.password)
@@ -71,7 +68,7 @@ func (c *Check) Run() error {
7168
resp, err := c.client.Do(req)
7269
if err != nil {
7370
if strings.Contains(err.Error(), "Timeout") {
74-
return fmt.Errorf("Timeout exceeded (%v)", c.client.Timeout)
71+
return fmt.Errorf("timeout exceeded (%v)", c.client.Timeout)
7572
}
7673

7774
return err
@@ -96,7 +93,7 @@ func (c *Check) AssertStatusCodeIn(codes []uint32) {
9693
}
9794
}
9895

99-
return fmt.Errorf("Unexpected status code: %s (expected: %v)", resp.Status, codes)
96+
return fmt.Errorf("unexpected status code: %s (expected: %v)", resp.Status, codes)
10097
})
10198
}
10299

@@ -105,7 +102,7 @@ func (c *Check) AssertHeaderExists(name, value string) {
105102
c.assertions = append(c.assertions, func(resp *http.Response) error {
106103
h := resp.Header.Get(name)
107104
if h != value {
108-
return fmt.Errorf("Expected header '%s' with value '%v'", name, value)
105+
return fmt.Errorf("expected header '%s' with value '%v'", name, value)
109106
}
110107

111108
return nil
@@ -115,13 +112,13 @@ func (c *Check) AssertHeaderExists(name, value string) {
115112
// AssertBodyContains tests if the body contains the specified string
116113
func (c *Check) AssertBodyContains(s string) {
117114
c.assertions = append(c.assertions, func(resp *http.Response) error {
118-
b, err := ioutil.ReadAll(resp.Body)
115+
b, err := io.ReadAll(resp.Body)
119116
if err != nil {
120-
return errors.Wrap(err, "Could not read body")
117+
return fmt.Errorf("could not read body: %w", err)
121118
}
122119

123120
if !strings.Contains(string(b), s) {
124-
return fmt.Errorf("String '%s' not found in body", s)
121+
return fmt.Errorf("string '%s' not found in body", s)
125122
}
126123

127124
return nil
@@ -131,18 +128,18 @@ func (c *Check) AssertBodyContains(s string) {
131128
// AssertBodyMatches tests if the body matches the specified regex
132129
func (c *Check) AssertBodyMatches(regex string) {
133130
c.assertions = append(c.assertions, func(resp *http.Response) error {
134-
b, err := ioutil.ReadAll(resp.Body)
131+
b, err := io.ReadAll(resp.Body)
135132
if err != nil {
136-
return errors.Wrap(err, "Could not read body")
133+
return fmt.Errorf("could not read body: %w", err)
137134
}
138135

139136
r, err := regexp.Compile(regex)
140137
if err != nil {
141-
return errors.Wrap(err, "Invalid regex")
138+
return fmt.Errorf("invalid regex: %w", err)
142139
}
143140

144141
if !r.Match(b) {
145-
return fmt.Errorf("Regex '%s' does not match body", regex)
142+
return fmt.Errorf("regex '%s' does not match body", regex)
146143
}
147144

148145
return nil
@@ -153,13 +150,13 @@ func (c *Check) AssertBodyMatches(regex string) {
153150
func (c *Check) AssertCertificateExpireDays(d time.Duration) {
154151
c.assertions = append(c.assertions, func(resp *http.Response) error {
155152
if resp.TLS == nil || len(resp.TLS.PeerCertificates) == 0 {
156-
return fmt.Errorf("No certificate returned")
153+
return fmt.Errorf("no certificate returned")
157154
}
158155

159156
first := resp.TLS.PeerCertificates[0]
160157
min := time.Now().Add(d)
161158
if !first.NotAfter.After(min) {
162-
return fmt.Errorf("Certificate expires on %v", first.NotAfter)
159+
return fmt.Errorf("certificate expires on %v", first.NotAfter)
163160
}
164161

165162
return nil

pkg/check/check_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestInvalidStausCode(t *testing.T) {
3737
c := NewCheck(s.Client(), s.URL)
3838
c.AssertStatusCodeIn([]uint32{200})
3939
err := c.Run()
40-
assert.EqualError(t, err, "Unexpected status code: 404 Not Found (expected: [200])")
40+
assert.EqualError(t, err, "unexpected status code: 404 Not Found (expected: [200])")
4141
}
4242

4343
func TestTimeoutHandling(t *testing.T) {
@@ -53,7 +53,7 @@ func TestTimeoutHandling(t *testing.T) {
5353

5454
c := NewCheck(cl, s.URL)
5555
err := c.Run()
56-
assert.EqualError(t, err, "Timeout exceeded (1ms)")
56+
assert.EqualError(t, err, "timeout exceeded (1ms)")
5757
}
5858

5959
func TestMissingHeader(t *testing.T) {
@@ -63,7 +63,7 @@ func TestMissingHeader(t *testing.T) {
6363
c := NewCheck(s.Client(), s.URL)
6464
c.AssertHeaderExists("X-Test", "Foo")
6565
err := c.Run()
66-
assert.EqualError(t, err, "Expected header 'X-Test' with value 'Foo'")
66+
assert.EqualError(t, err, "expected header 'X-Test' with value 'Foo'")
6767
}
6868

6969
func TestInvalidBody(t *testing.T) {
@@ -73,7 +73,7 @@ func TestInvalidBody(t *testing.T) {
7373
c := NewCheck(s.Client(), s.URL)
7474
c.AssertBodyContains("Mauve")
7575
err := c.Run()
76-
assert.EqualError(t, err, "String 'Mauve' not found in body")
76+
assert.EqualError(t, err, "string 'Mauve' not found in body")
7777
}
7878

7979
func TestInvalidBodyWithRegex(t *testing.T) {
@@ -83,7 +83,7 @@ func TestInvalidBodyWithRegex(t *testing.T) {
8383
c := NewCheck(s.Client(), s.URL)
8484
c.AssertBodyMatches("^\\d{5}$")
8585
err := c.Run()
86-
assert.EqualError(t, err, "Regex '^\\d{5}$' does not match body")
86+
assert.EqualError(t, err, "regex '^\\d{5}$' does not match body")
8787
}
8888

8989
func TestValidBodyWithRegex(t *testing.T) {
@@ -150,7 +150,7 @@ func TestAssertCertificateExpireDaysWithoutCert(t *testing.T) {
150150
err := c.validate(resp)
151151

152152
assert.NotNil(t, err)
153-
assert.Equal(t, err.Error(), "No certificate returned")
153+
assert.Equal(t, err.Error(), "no certificate returned")
154154
}
155155

156156
func TestAssertCertificateExpireDaysWithSoonExpiringCert(t *testing.T) {
@@ -173,7 +173,7 @@ func TestAssertCertificateExpireDaysWithSoonExpiringCert(t *testing.T) {
173173
err := c.validate(resp)
174174

175175
assert.NotNil(t, err)
176-
assert.Equal(t, err.Error(), fmt.Sprintf("Certificate expires on %v", notAfter))
176+
assert.Equal(t, err.Error(), fmt.Sprintf("certificate expires on %v", notAfter))
177177
}
178178

179179
func mockServer(status int, body string, headers http.Header) *httptest.Server {

0 commit comments

Comments
 (0)