From 635ac451c09a1310b5e607d366fcf3bc16418a96 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Sun, 11 Dec 2022 14:58:40 +0100 Subject: [PATCH] Fix linter findings for: goerr113 --- .golangci.yaml | 3 +-- internal/types/errors.go | 3 +++ srv.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index a6260b8..e516efd 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -19,11 +19,10 @@ linters: - noctx - funlen - nestif + - gocognit - interfacer - revive - cyclop - - goerr113 - - gocognit # deprecated: - scopelint diff --git a/internal/types/errors.go b/internal/types/errors.go index 89d438d..62c36f1 100644 --- a/internal/types/errors.go +++ b/internal/types/errors.go @@ -6,4 +6,7 @@ var ( ErrNotFound = errors.New("cache entry not found") ErrInvalidCacheEntry = errors.New("invalid cache entry format") ErrUpstream = errors.New("upstream error") + + // ErrNoServersConfigured means that there are no servers to run. + ErrNoServersConfigured = errors.New("no servers configured") ) diff --git a/srv.go b/srv.go index 22b26d7..8f4e88d 100644 --- a/srv.go +++ b/srv.go @@ -2,7 +2,6 @@ package main import ( "crypto/tls" - "errors" "fmt" "io" "log" @@ -16,6 +15,7 @@ import ( geoloc "github.com/chubin/wttr.in/internal/geo/location" "github.com/chubin/wttr.in/internal/logging" "github.com/chubin/wttr.in/internal/processor" + "github.com/chubin/wttr.in/internal/types" ) //nolint:gochecknoglobals @@ -158,7 +158,7 @@ func serve(conf *config.Config) error { numberOfServers++ } if numberOfServers == 0 { - return errors.New("no servers configured") + return types.ErrNoServersConfigured } return <-errs // block until one of the servers writes an error