chore: update to go1.22 (#2144)

This commit is contained in:
Ludovic Fernandez 2024-03-20 20:30:35 +01:00 committed by GitHub
parent 874e3ea023
commit 3371145f01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
58 changed files with 18 additions and 87 deletions

View file

@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
go-version: [ stable, oldstable ]
go-version: [ stable ]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:

View file

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.56.1
GOLANGCI_LINT_VERSION: v1.57.1
HUGO_VERSION: 0.117.0
CGO_ENABLED: 0
LEGO_E2E_TESTS: CI

View file

@ -1,10 +1,10 @@
run:
timeout: 10m
skip-files: []
linters-settings:
govet:
check-shadowing: true
enable:
- shadow
gocyclo:
min-complexity: 12
goconst:
@ -139,6 +139,7 @@ linters:
- nonamedreturns
- musttag # false-positive https://github.com/junk1tm/musttag/issues/17
- gosmopolitan # not relevant
- exportloopref # Useless with go1.22
issues:
exclude-use-default: false
@ -148,7 +149,7 @@ issues:
- 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked'
- 'exported (type|method|function) (.+) should have comment or be unexported'
- 'ST1000: at least one file in a package should have a package comment'
- 'fmt.Sprintf can be replaced with string addition'
- 'fmt.Sprintf can be replaced with string'
exclude-rules:
- path: (.+)_test.go
linters:

View file

@ -94,7 +94,6 @@ func TestOrderService_NewWithOptions(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -44,7 +44,6 @@ func Test_getLink(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -86,7 +86,6 @@ func TestGenerateCSR(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -38,7 +38,7 @@ func (c *Certifier) getAuthorizations(order acme.ExtendedOrder) ([]acme.Authoriz
var responses []acme.Authorization
failures := newObtainError()
for i := 0; i < len(order.Authorizations); i++ {
for range len(order.Authorizations) {
select {
case res := <-resc:
responses = append(responses, res)

View file

@ -112,7 +112,6 @@ func TestCertifier_GetRenewalInfo_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -215,7 +215,7 @@ func getChallengeFQDN(domain string, followCNAME bool) string {
}
// recursion counter so it doesn't spin out of control
for limit := 0; limit < 50; limit++ {
for range 50 {
// Keep following CNAMEs
r, err := dnsQuery(fqdn, dns.TypeCNAME, recursiveNameservers, true)

View file

@ -47,7 +47,6 @@ func TestExtractSubDomain(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -93,7 +92,6 @@ func TestExtractSubDomain_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -25,7 +25,6 @@ func TestToFqdn(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -54,7 +53,6 @@ func TestUnFqdn(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -30,7 +30,6 @@ func TestLookupNameserversOK(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.fqdn, func(t *testing.T) {
t.Parallel()
@ -59,7 +58,6 @@ func TestLookupNameserversErr(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -259,7 +257,6 @@ func TestDNSError_Error(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -28,7 +28,6 @@ func TestCheckDNSPropagation(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
ClearFqdnCache()
@ -69,7 +68,6 @@ func TestCheckAuthoritativeNss(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
ClearFqdnCache()
@ -104,7 +102,6 @@ func TestCheckAuthoritativeNssErr(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
ClearFqdnCache()

View file

@ -69,7 +69,6 @@ func TestParseForwardedHeader(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

View file

@ -57,7 +57,6 @@ func TestProviderServer_GetAddress(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -99,7 +99,6 @@ func TestProber_Solve(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -48,7 +48,6 @@ func Test_merge(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -108,7 +107,6 @@ func Test_needRenewal(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
actual := needRenewal(test.x509Cert, "foo.com", test.days)

View file

@ -66,7 +66,7 @@ docker run goacme/lego -h
Requirements:
- go1.17+
- go1.22+.
- environment variable: `GO111MODULE=on`
To install the latest version from sources, just run:

2
go.mod
View file

@ -1,6 +1,6 @@
module github.com/go-acme/lego/v4
go 1.21
go 1.22
// github.com/exoscale/egoscale v1.19.0 => It is an error, please don't use it.

View file

@ -93,7 +93,6 @@ func TestGetWithFallback(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -166,7 +165,6 @@ func TestGetOneWithFallback(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -76,8 +76,7 @@ func (d *DNSProviderPrivate) Present(domain, _, keyAuth string) error {
var txtRecords []*armprivatedns.TxtRecord
for txt := range uniqRecords {
txtRecord := txt
txtRecords = append(txtRecords, &armprivatedns.TxtRecord{Value: to.SliceOfPtrs(txtRecord)})
txtRecords = append(txtRecords, &armprivatedns.TxtRecord{Value: to.SliceOfPtrs(txt)})
}
rec := armprivatedns.RecordSet{

View file

@ -75,8 +75,7 @@ func (d *DNSProviderPublic) Present(domain, _, keyAuth string) error {
var txtRecords []*armdns.TxtRecord
for txt := range uniqRecords {
txtRecord := txt
txtRecords = append(txtRecords, &armdns.TxtRecord{Value: to.SliceOfPtrs(txtRecord)})
txtRecords = append(txtRecords, &armdns.TxtRecord{Value: to.SliceOfPtrs(txt)})
}
rec := armdns.RecordSet{

View file

@ -119,7 +119,6 @@ resources
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -38,7 +38,6 @@ func TestClient_buildQuery(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -55,7 +55,6 @@ func Test_getMainDomain(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -92,7 +92,6 @@ func TestGetRootDomain(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -181,7 +180,6 @@ func TestGetRecords(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -232,7 +230,6 @@ func TestAddNewRecord(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -290,7 +287,6 @@ func TestDeleteRecord(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -169,7 +169,6 @@ func TestDNSProvider_findZone(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -161,7 +161,6 @@ func TestDNSProvider_FindZoneAndRecordName(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -131,7 +131,6 @@ func Test_extractAllZones(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -152,7 +152,6 @@ func TestNewDNSProvider_Present(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -229,7 +228,6 @@ func TestNewDNSProvider_Cleanup(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -46,7 +46,6 @@ func TestClient_UpdateTxtRecord(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.code, func(t *testing.T) {
t.Parallel()

View file

@ -228,7 +228,7 @@ func splitDomain(domain string, zones []string) (string, string, error) {
var owner string
var zone string
for i := 0; i < len(parts)-1; i++ {
for i := range len(parts) - 1 {
zone = strings.Join(parts[i:], ".")
if slices.Contains(zones, zone) {
baseOwner := strings.Join(parts[0:i], ".")

View file

@ -190,7 +190,6 @@ func TestSplitDomain(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -171,7 +171,6 @@ func Test_computeSleep(t *testing.T) {
require.NoError(t, err)
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -188,7 +188,6 @@ func findZone(zones []internal.Zone, domain string) *internal.Zone {
var result *internal.Zone
for _, zone := range zones {
zone := zone
if zone.Name != "" && strings.HasSuffix(domain, zone.Name) {
if result == nil || len(zone.Name) > len(result.Name) {
result = &zone

View file

@ -78,7 +78,6 @@ func Test_splitDomain(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -170,7 +170,6 @@ func Test_parseResponse(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -221,7 +220,6 @@ func Test_RemoveTxtEntryFromZone(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -238,7 +238,6 @@ func TestDNSProvider(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
provider := setupTest(t, test.initRecs...)

View file

@ -180,7 +180,6 @@ func findZone(zones []internal.DNSZone, domain string) *internal.DNSZone {
var result *internal.DNSZone
for _, zone := range zones {
zone := zone
if zone.Name != "" && strings.HasSuffix(domain, zone.Name) {
if result == nil || len(zone.Name) > len(result.Name) {
result = &zone

View file

@ -184,7 +184,6 @@ func TestDNSProvider_findZone(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -203,7 +203,6 @@ func TestDomainSplit(t *testing.T) {
}
for _, test := range tests {
test := test
t.Run(test.domain, func(t *testing.T) {
valid := true
ch, err := newChallenge(test.domain, "")

View file

@ -135,7 +135,7 @@ func (c Signer) Sign(uri string, body, login, apiKey string) string {
func getRandomSalt() []byte {
// This is the only part of this that needs to be serialized.
salt := make([]byte, 16)
for i := 0; i < 16; i++ {
for i := range 16 {
salt[i] = saltBytes[rand.Intn(len(saltBytes))]
}

View file

@ -199,7 +199,6 @@ func TestSigner_Sign(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
signer := NewSigner()

View file

@ -124,7 +124,6 @@ func TestGetDNSRecordIdx(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -288,7 +287,6 @@ func TestClient_GetDNSRecords_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -115,7 +115,6 @@ func TestClient_Login_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -202,7 +201,6 @@ func TestClient_Logout_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -230,9 +228,8 @@ func TestLiveClientAuth(t *testing.T) {
envTest.GetValue("NETCUP_API_PASSWORD"))
require.NoError(t, err)
for i := 1; i < 4; i++ {
i := i
t.Run("Test_"+strconv.Itoa(i), func(t *testing.T) {
for i := range 4 {
t.Run("Test_"+strconv.Itoa(i+1), func(t *testing.T) {
t.Parallel()
ctx, err := client.CreateSessionContext(context.Background())

View file

@ -89,7 +89,6 @@ func TestChangeResourceRecordSetsErrors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
client := setupTest(t, test.responseBody, test.statusCode)
@ -157,7 +156,6 @@ func TestGetChangeErrors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
client := setupTest(t, test.responseBody, test.statusCode)

View file

@ -144,7 +144,6 @@ func TestClient_joinPath(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -61,7 +61,6 @@ func TestRemoveRecord_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -119,7 +118,6 @@ func TestAddTXTRecord_errors(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -93,7 +93,7 @@ func TestDNSProvider_concurrentAddAndCleanupRecords(t *testing.T) {
dummyRecordCount := 10
var providers []*DNSProvider
for i := 0; i < dummyRecordCount; i++ {
for range dummyRecordCount {
config := NewDefaultConfig()
config.Token = "token3"
config.Secret = "secret3"

View file

@ -222,7 +222,6 @@ func TestTTLRounder(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -48,7 +48,6 @@ func TestClient_SetRecord(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -121,7 +121,6 @@ func TestNewDNSProviderConfig(t *testing.T) {
}
for desc, test := range testCases {
test := test
t.Run(desc, func(t *testing.T) {
t.Parallel()

View file

@ -188,7 +188,6 @@ func TestDNSProvider_Present(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -139,7 +139,7 @@ func TestDNSProvider_getHostedZone(t *testing.T) {
domains := []govultr.Domain{{Domain: "example.com"}, {Domain: "example.org"}, {Domain: "example.net"}}
for i := 0; i < 50; i++ {
for i := range 50 {
domains = append(domains, govultr.Domain{Domain: fmt.Sprintf("my%02d.example.com", i)})
}
@ -157,7 +157,6 @@ func TestDNSProvider_getHostedZone(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -91,7 +91,6 @@ func TestClient_AddTXTRecord(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -132,7 +131,6 @@ func TestClient_RemoveTxtRecord(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

View file

@ -309,7 +309,6 @@ func TestGetRecords(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
client, mux := setupTest(t)

View file

@ -131,7 +131,6 @@ func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
var record *internal.Record
for _, rcd := range records {
rcd := rcd
if rcd.Type == "TXT" && rcd.SubDomain == subDomain && rcd.Content == info.Value {
record = &rcd
break

View file

@ -178,7 +178,6 @@ func TestDNSProvider_Present(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -187,7 +186,6 @@ func TestDNSProvider_Present(t *testing.T) {
t.Cleanup(server.Close)
for uri, handler := range test.handlers {
handler := handler
mux.HandleFunc(uri, handler)
}
@ -270,7 +268,6 @@ func TestDNSProvider_Cleanup(t *testing.T) {
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -279,7 +276,6 @@ func TestDNSProvider_Cleanup(t *testing.T) {
t.Cleanup(server.Close)
for uri, handler := range test.handlers {
handler := handler
mux.HandleFunc(uri, handler)
}