Fix linter findings for: goerr113

This commit is contained in:
Igor Chubin 2022-12-11 14:58:40 +01:00
parent 173b501a2d
commit 635ac451c0
3 changed files with 6 additions and 4 deletions

View File

@ -19,11 +19,10 @@ linters:
- noctx - noctx
- funlen - funlen
- nestif - nestif
- gocognit
- interfacer - interfacer
- revive - revive
- cyclop - cyclop
- goerr113
- gocognit
# deprecated: # deprecated:
- scopelint - scopelint

View File

@ -6,4 +6,7 @@ var (
ErrNotFound = errors.New("cache entry not found") ErrNotFound = errors.New("cache entry not found")
ErrInvalidCacheEntry = errors.New("invalid cache entry format") ErrInvalidCacheEntry = errors.New("invalid cache entry format")
ErrUpstream = errors.New("upstream error") ErrUpstream = errors.New("upstream error")
// ErrNoServersConfigured means that there are no servers to run.
ErrNoServersConfigured = errors.New("no servers configured")
) )

4
srv.go
View File

@ -2,7 +2,6 @@ package main
import ( import (
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"io" "io"
"log" "log"
@ -16,6 +15,7 @@ import (
geoloc "github.com/chubin/wttr.in/internal/geo/location" geoloc "github.com/chubin/wttr.in/internal/geo/location"
"github.com/chubin/wttr.in/internal/logging" "github.com/chubin/wttr.in/internal/logging"
"github.com/chubin/wttr.in/internal/processor" "github.com/chubin/wttr.in/internal/processor"
"github.com/chubin/wttr.in/internal/types"
) )
//nolint:gochecknoglobals //nolint:gochecknoglobals
@ -158,7 +158,7 @@ func serve(conf *config.Config) error {
numberOfServers++ numberOfServers++
} }
if numberOfServers == 0 { if numberOfServers == 0 {
return errors.New("no servers configured") return types.ErrNoServersConfigured
} }
return <-errs // block until one of the servers writes an error return <-errs // block until one of the servers writes an error