diff --git a/.golangci.yml b/.golangci.yml index 37073ca..999c630 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -43,7 +43,6 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/ enable: - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers - bidichk # Checks for dangerous unicode character sequences - - deadcode # Finds unused code - depguard # Go linter that checks if package imports are in a list of acceptable packages - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - dupl # Tool for code clone detection @@ -78,7 +77,6 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/ - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code - unconvert # Remove unnecessary type conversions - unused # Checks Go code for unused constants, variables, functions and types - - varcheck # Finds unused global variables and constants - whitespace # Tool for detection of leading and trailing whitespace - wsl # Whitespace Linter - Forces you to use empty lines! diff --git a/internal/checkers/health_test.go b/internal/checkers/health_test.go index 85bdb77..a567e57 100644 --- a/internal/checkers/health_test.go +++ b/internal/checkers/health_test.go @@ -3,11 +3,12 @@ package checkers_test import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "testing" "github.com/stretchr/testify/assert" + "github.com/tarampampam/error-pages/internal/checkers" ) @@ -22,7 +23,7 @@ func TestHealthChecker_CheckSuccess(t *testing.T) { assert.Equal(t, "HealthChecker/internal", req.Header.Get("User-Agent")) return &http.Response{ - Body: ioutil.NopCloser(bytes.NewReader([]byte{})), + Body: io.NopCloser(bytes.NewReader([]byte{})), StatusCode: http.StatusOK, }, nil } @@ -35,7 +36,7 @@ func TestHealthChecker_CheckSuccess(t *testing.T) { func TestHealthChecker_CheckFail(t *testing.T) { var httpMock httpClientFunc = func(req *http.Request) (*http.Response, error) { return &http.Response{ - Body: ioutil.NopCloser(bytes.NewReader([]byte{})), + Body: io.NopCloser(bytes.NewReader([]byte{})), StatusCode: http.StatusBadGateway, }, nil } diff --git a/internal/cli/healthcheck/command.go b/internal/cli/healthcheck/command.go index 283b9fa..d3ceb36 100644 --- a/internal/cli/healthcheck/command.go +++ b/internal/cli/healthcheck/command.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "github.com/tarampampam/error-pages/internal/env" ) @@ -29,7 +30,7 @@ func NewCommand(checker checker) *cobra.Command { // flag was NOT defined using CLI (flags should have maximal priority) if !flag.Changed && flag.Name == portFlagName { if envPort, exists := env.ListenPort.Lookup(); exists && envPort != "" { - if p, err := strconv.ParseUint(envPort, 10, 16); err == nil { //nolint:gomnd + if p, err := strconv.ParseUint(envPort, 10, 16); err == nil { port = uint16(p) } else { lastErr = fmt.Errorf("wrong TCP port environment variable [%s] value", envPort) diff --git a/internal/cli/serve/flags.go b/internal/cli/serve/flags.go index 457a006..37c5292 100644 --- a/internal/cli/serve/flags.go +++ b/internal/cli/serve/flags.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/spf13/pflag" + "github.com/tarampampam/error-pages/internal/env" "github.com/tarampampam/error-pages/internal/options" ) @@ -118,7 +119,7 @@ func (f *flags) OverrideUsingEnv(flagSet *pflag.FlagSet) (lastErr error) { //nol case portFlagName: if envVar, exists := env.ListenPort.Lookup(); exists { - if p, err := strconv.ParseUint(envVar, 10, 16); err == nil { //nolint:gomnd + if p, err := strconv.ParseUint(envVar, 10, 16); err == nil { f.Listen.Port = uint16(p) } else { lastErr = fmt.Errorf("wrong TCP port environment variable [%s] value", envVar) @@ -137,7 +138,7 @@ func (f *flags) OverrideUsingEnv(flagSet *pflag.FlagSet) (lastErr error) { //nol case defaultHTTPCodeFlagName: if envVar, exists := env.DefaultHTTPCode.Lookup(); exists { - if code, err := strconv.ParseUint(envVar, 10, 16); err == nil { //nolint:gomnd + if code, err := strconv.ParseUint(envVar, 10, 16); err == nil { f.defaultHTTPCode = uint16(code) } else { lastErr = fmt.Errorf("wrong default HTTP response code environment variable [%s] value", envVar) diff --git a/internal/config/config.go b/internal/config/config.go index 5eeb995..eba89f9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,7 +1,6 @@ package config import ( - "io/ioutil" "os" "path" "path/filepath" @@ -68,7 +67,7 @@ func (t Template) Name() string { return t.name } func (t Template) Content() []byte { return t.content } func (t *Template) loadContentFromFile(filePath string) (err error) { - if t.content, err = ioutil.ReadFile(filePath); err != nil { + if t.content, err = os.ReadFile(filePath); err != nil { return errors.Wrap(err, "cannot load content for the template "+t.Name()+" from file "+filePath) } @@ -236,7 +235,7 @@ func FromYaml(in []byte) (_ *Config, err error) { // FromYamlFile creates new Config instance using YAML file. func FromYamlFile(filepath string) (*Config, error) { - bytes, err := ioutil.ReadFile(filepath) + bytes, err := os.ReadFile(filepath) if err != nil { return nil, errors.Wrap(err, "cannot read configuration file") } diff --git a/internal/http/core/formats.go b/internal/http/core/formats.go index e592c04..06da587 100644 --- a/internal/http/core/formats.go +++ b/internal/http/core/formats.go @@ -39,7 +39,7 @@ func ClientWantFormat(ctx *fasthttp.RequestCtx) ContentType { f := format{b[0:idx], 0} if len(b) > idx+3 { - if weight, err := strconv.ParseFloat(string(b[idx+3:]), 32); err == nil { //nolint:gomnd + if weight, err := strconv.ParseFloat(string(b[idx+3:]), 32); err == nil { f.weight = float32(weight) } }