Skip to content

Commit 28d66b1

Browse files
authored
Merge pull request #397 from crazy-max/go-1.23
update go to 1.23
2 parents eeced34 + 4635752 commit 28d66b1

File tree

10 files changed

+89
-31
lines changed

10 files changed

+89
-31
lines changed

.golangci.yml

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,93 @@
11
run:
22
timeout: 10m
3+
# default uses Go version from the go.mod file, fallback on the env var
4+
# `GOVERSION`, fallback on 1.17: https://golangci-lint.run/usage/configuration/#run-configuration
5+
go: "1.23"
36

47
linters:
58
enable:
9+
- bodyclose
610
- depguard
11+
- forbidigo
12+
- gocritic
713
- gofmt
814
- goimports
9-
- revive
15+
- gosec
16+
- gosimple
1017
- govet
11-
- importas
1218
- ineffassign
19+
- makezero
1320
- misspell
21+
- noctx
22+
- nolintlint
23+
- revive
24+
- staticcheck
25+
- testifylint
1426
- typecheck
15-
- errname
16-
- makezero
17-
- whitespace
1827
- unused
28+
- whitespace
1929
disable-all: true
2030

2131
linters-settings:
32+
gocritic:
33+
disabled-checks:
34+
- "ifElseChain"
35+
- "assignOp"
36+
- "appendAssign"
37+
- "singleCaseSwitch"
38+
- "exitAfterDefer" # FIXME
39+
govet:
40+
enable:
41+
- nilness
42+
- unusedwrite
2243
depguard:
2344
rules:
2445
main:
2546
deny:
26-
# The io/ioutil package has been deprecated.
27-
# https://go.dev/doc/go1.16#ioutil
2847
- pkg: "io/ioutil"
2948
desc: The io/ioutil package has been deprecated.
30-
importas:
31-
no-unaliased: true
49+
forbidigo:
50+
forbid:
51+
- '^fmt\.Errorf(# use errors\.Errorf instead)?$'
52+
gosec:
53+
excludes:
54+
- G106 # Use of ssh InsecureIgnoreHostKey should be audited
55+
- G115 # integer overflow conversion
56+
- G204 # Audit use of command execution
57+
- G402 # TLS MinVersion too low
58+
config:
59+
G306: "0644"
60+
testifylint:
61+
disable:
62+
# disable rules that reduce the test condition
63+
- "empty"
64+
- "bool-compare"
65+
- "len"
66+
- "negative-positive"
3267

3368
issues:
69+
exclude-files:
70+
- ".*\\.pb\\.go$"
3471
exclude-rules:
3572
- linters:
3673
- revive
3774
text: "stutters"
75+
- linters:
76+
- revive
77+
text: "empty-block"
78+
- linters:
79+
- revive
80+
text: "superfluous-else"
81+
- linters:
82+
- revive
83+
text: "unused-parameter"
84+
- linters:
85+
- revive
86+
text: "redefines-builtin-id"
87+
- linters:
88+
- revive
89+
text: "if-return"
3890

39-
# show all
40-
max-issues-per-linter: 0
41-
max-same-issues: 0
91+
# show all
92+
max-issues-per-linter: 0
93+
max-same-issues: 0

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION="1.21"
4-
ARG ALPINE_VERSION="3.18"
3+
ARG GO_VERSION="1.23"
4+
ARG ALPINE_VERSION="3.21"
55
ARG XX_VERSION="1.6.1"
66

77
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535
runtime.GOMAXPROCS(runtime.NumCPU())
3636

3737
meta.Version = version
38-
meta.UserAgent = fmt.Sprintf("%s/%s go/%s %s", meta.ID, meta.Version, runtime.Version()[2:], strings.Title(runtime.GOOS))
38+
meta.UserAgent = fmt.Sprintf("%s/%s go/%s %s", meta.ID, meta.Version, runtime.Version()[2:], strings.Title(runtime.GOOS)) //nolint:staticcheck // ignoring "SA1019: strings.Title is deprecated", as for our use we don't need full unicode support
3939
if meta.Hostname, err = os.Hostname(); err != nil {
4040
log.Fatal().Err(err).Msg("Cannot resolve hostname")
4141
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/crazy-max/ftpgrab/v7
22

3-
go 1.21
3+
go 1.23.0
44

55
require (
66
github.com/alecthomas/kong v1.6.0

hack/lint.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION="1.21"
4-
ARG ALPINE_VERSION="3.18"
5-
ARG GOLANGCI_LINT_VERSION="v1.55"
3+
ARG GO_VERSION="1.23"
4+
ARG ALPINE_VERSION="3.21"
5+
ARG GOLANGCI_LINT_VERSION="v1.62"
66

77
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
88
ENV GOFLAGS="-buildvcs=false"

hack/vendor.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax=docker/dockerfile:1
22

3-
ARG GO_VERSION="1.21"
4-
ARG ALPINE_VERSION="3.18"
3+
ARG GO_VERSION="1.23"
4+
ARG ALPINE_VERSION="3.21"
55
ARG GOMOD_OUTDATED_VERSION="v0.8.0"
66

77
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base

internal/journal/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ func (c *Client) Add(entry Entry) {
2525

2626
// IsEmpty checks if journal is empty
2727
func (c *Client) IsEmpty() bool {
28-
return c.Entries == nil || len(c.Entries) == 0
28+
return len(c.Entries) == 0
2929
}

internal/journal/journal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ func (j Journal) MarshalJSON() ([]byte, error) {
3333

3434
// IsEmpty checks if journal is empty
3535
func (j Journal) IsEmpty() bool {
36-
return j.Entries == nil || len(j.Entries) == 0
36+
return len(j.Entries) == 0
3737
}

internal/notif/script/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ func (c *Client) Send(jnl journal.Journal) error {
7878
return errors.Wrap(err, strings.TrimSpace(stderr.String()))
7979
}
8080

81-
log.Debug().Msgf(strings.TrimSpace(stdout.String()))
81+
log.Debug().Msg(strings.TrimSpace(stdout.String()))
8282
return nil
8383
}

internal/notif/webhook/client.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package webhook
22

33
import (
44
"bytes"
5+
"context"
56
"encoding/json"
67
"net/http"
78

@@ -34,10 +35,6 @@ func (c *Client) Name() string {
3435

3536
// Send creates and sends a webhook notification with journal entries
3637
func (c *Client) Send(jnl journal.Journal) error {
37-
hc := http.Client{
38-
Timeout: *c.cfg.Timeout,
39-
}
40-
4138
body, err := json.Marshal(struct {
4239
Version string `json:"ftpgrab_version,omitempty"`
4340
ServerIP string `json:"server_ip,omitempty"`
@@ -53,7 +50,11 @@ func (c *Client) Send(jnl journal.Journal) error {
5350
return err
5451
}
5552

56-
req, err := http.NewRequest(c.cfg.Method, c.cfg.Endpoint, bytes.NewBuffer(body))
53+
hc := http.Client{}
54+
ctx, cancel := context.WithTimeout(context.Background(), *c.cfg.Timeout)
55+
defer cancel()
56+
57+
req, err := http.NewRequestWithContext(ctx, c.cfg.Method, c.cfg.Endpoint, bytes.NewBuffer(body))
5758
if err != nil {
5859
return err
5960
}
@@ -66,6 +67,11 @@ func (c *Client) Send(jnl journal.Journal) error {
6667

6768
req.Header.Set("User-Agent", c.meta.UserAgent)
6869

69-
_, err = hc.Do(req)
70-
return err
70+
resp, err := hc.Do(req)
71+
if err != nil {
72+
return err
73+
}
74+
defer resp.Body.Close()
75+
76+
return nil
7177
}

0 commit comments

Comments
 (0)