diff --git a/.golangci.yml b/.golangci.yml index 22d2518..ebad992 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -74,7 +74,6 @@ linters: enable-all: true disable: - gci - - exhaustivestruct - exhaustruct - gochecknoglobals - whitespace @@ -83,21 +82,13 @@ linters: - nlreturn - gofmt - gofumpt - - varcheck - - golint - - structcheck - - nosnakecase - - maligned - - interfacer - - deadcode - - scopelint - - ifshort - godox - forbidigo - - goerr113 + - err113 - nonamedreturns - staticcheck - depguard + - intrange #Пока не пересели на go1.22+ fast: false issues: diff --git a/core/config/config.go b/core/config/config.go index 061420e..7f96534 100644 --- a/core/config/config.go +++ b/core/config/config.go @@ -2,6 +2,7 @@ package config import ( "database/sql" + "errors" "fmt" "io/ioutil" "os" @@ -98,7 +99,7 @@ func DialDSN(dsn string) (db *sql.DB, dbname string, err error) { driver = "mysql" dsn = strings.TrimLeft(dsn, "mysql://") default: - return nil, "", fmt.Errorf("can't use unknown SQL dialect") + return nil, "", errors.New("can't use unknown SQL dialect") } db, err = sql.Open(driver, dsn) @@ -116,7 +117,7 @@ func (s Interface) SetFromDB(database *sql.DB, _ string) error { // TODO: Перенести это в параметры. table := "config" - q := "SELECT " + table + ".key, " + table + ".value FROM " + table + q := fmt.Sprintf("SELECT %s.key, %s.value FROM %s", table, table, table) results, err := database.Query(q) if err != nil || results.Err() != nil { return fmt.Errorf("can't get key-value pairs from DB: %w", err) diff --git a/core/config/internal.go b/core/config/internal.go index 04ef788..cde5604 100644 --- a/core/config/internal.go +++ b/core/config/internal.go @@ -1,6 +1,7 @@ package config import ( + "errors" "fmt" "os" "reflect" @@ -10,7 +11,7 @@ import ( func getEnvVar(value reflect.Value, rtype reflect.Type, counter int, prefix string) error { if value.Kind() != reflect.Ptr { - return fmt.Errorf("not a pointer value") + return errors.New("not a pointer value") } f := reflect.StructField{} if counter != -1 { @@ -38,7 +39,7 @@ func getEnvVar(value reflect.Value, rtype reflect.Type, counter int, prefix stri func parseToStruct(value reflect.Value, rtype reflect.Type, counter int, prefix string, index map[string]string) error { if value.Kind() != reflect.Ptr { - return fmt.Errorf("not a pointer value") + return errors.New("not a pointer value") } f := reflect.StructField{} if counter != -1 { diff --git a/core/logger/logger.go b/core/logger/logger.go index b018d25..14d35bb 100644 --- a/core/logger/logger.go +++ b/core/logger/logger.go @@ -71,6 +71,5 @@ func (l *Logger) Errorf(format string, args ...interface{}) { func (l *Logger) Fatalf(format string, args ...interface{}) { l.Logger.Fatalf(format, args) - //nolint:gomnd - os.Exit(2) + os.Exit(2) //nolint:mnd }