diff --git a/.golangci.yml b/.golangci.yml index ec011fd92..8fece2524 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,6 +37,7 @@ linters: - errname - errorlint - exhaustive + - fatcontext - forcetypeassert - gci - gocheckcompilerdirectives @@ -59,10 +60,12 @@ linters: - importas - inamedparam - interfacebloat + - intrange - ireturn - lll - maintidx - makezero + - mirror - misspell - mnd - musttag diff --git a/internal/update/getip.go b/internal/update/getip.go index 2187a4c64..79d91924d 100644 --- a/internal/update/getip.go +++ b/internal/update/getip.go @@ -21,7 +21,7 @@ func tryAndRepeatGettingIP(ctx context.Context, getIPFunc getIPFunc, const tries = 3 logMessagePrefix := "obtaining " + version.String() + " address" errs := make([]error, 0, tries) - for try := 0; try < tries; try++ { + for try := range tries { ip, err = getIPFunc(ctx) if err != nil { errs = append(errs, err) diff --git a/internal/update/service.go b/internal/update/service.go index 3a9199050..16436c8c0 100644 --- a/internal/update/service.go +++ b/internal/update/service.go @@ -54,7 +54,7 @@ func NewService(db Database, updater UpdaterInterface, ipGetter PublicIPFetcher, func (s *Service) lookupIPsResilient(ctx context.Context, hostname string, tries int) ( ipv4 netip.Addr, ipv6 netip.Addr, err error, ) { - for i := 0; i < tries; i++ { + for range tries { ipv4, ipv6, err = s.lookupIPs(ctx, hostname) if err == nil { return ipv4, ipv6, nil diff --git a/pkg/publicip/info/provider.go b/pkg/publicip/info/provider.go index 68778cbaf..6f78ae5d7 100644 --- a/pkg/publicip/info/provider.go +++ b/pkg/publicip/info/provider.go @@ -37,8 +37,7 @@ type provider interface { get(ctx context.Context, ip netip.Addr) (result Result, err error) } -//nolint:ireturn -func newProvider(providerName Provider, client *http.Client) provider { +func newProvider(providerName Provider, client *http.Client) provider { //nolint:ireturn switch providerName { case Ipinfo: return newIpinfo(client) diff --git a/pkg/publicip/subfetcher.go b/pkg/publicip/subfetcher.go index 43ae82b0f..992366f65 100644 --- a/pkg/publicip/subfetcher.go +++ b/pkg/publicip/subfetcher.go @@ -4,7 +4,8 @@ import ( "sync/atomic" ) -func (f *Fetcher) getSubFetcher() ipFetcher { //nolint:ireturn +//nolint:ireturn +func (f *Fetcher) getSubFetcher() ipFetcher { fetcher := f.fetchers[0] if len(f.fetchers) > 1 { // cycling effect index := int(atomic.AddUint32(f.counter, 1)) % len(f.fetchers)