Lint
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
23b53d352e
commit
1850093a07
|
@ -74,7 +74,6 @@ linters:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
disable:
|
disable:
|
||||||
- gci
|
- gci
|
||||||
- exhaustivestruct
|
|
||||||
- exhaustruct
|
- exhaustruct
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
- whitespace
|
- whitespace
|
||||||
|
@ -83,21 +82,13 @@ linters:
|
||||||
- nlreturn
|
- nlreturn
|
||||||
- gofmt
|
- gofmt
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- varcheck
|
|
||||||
- golint
|
|
||||||
- structcheck
|
|
||||||
- nosnakecase
|
|
||||||
- maligned
|
|
||||||
- interfacer
|
|
||||||
- deadcode
|
|
||||||
- scopelint
|
|
||||||
- ifshort
|
|
||||||
- godox
|
- godox
|
||||||
- forbidigo
|
- forbidigo
|
||||||
- goerr113
|
- err113
|
||||||
- nonamedreturns
|
- nonamedreturns
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- depguard
|
- depguard
|
||||||
|
- intrange #Пока не пересели на go1.22+
|
||||||
fast: false
|
fast: false
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
|
|
|
@ -2,6 +2,7 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
@ -98,7 +99,7 @@ func DialDSN(dsn string) (db *sql.DB, dbname string, err error) {
|
||||||
driver = "mysql"
|
driver = "mysql"
|
||||||
dsn = strings.TrimLeft(dsn, "mysql://")
|
dsn = strings.TrimLeft(dsn, "mysql://")
|
||||||
default:
|
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)
|
db, err = sql.Open(driver, dsn)
|
||||||
|
@ -116,7 +117,7 @@ func (s Interface) SetFromDB(database *sql.DB, _ string) error {
|
||||||
|
|
||||||
// TODO: Перенести это в параметры.
|
// TODO: Перенести это в параметры.
|
||||||
table := "config"
|
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)
|
results, err := database.Query(q)
|
||||||
if err != nil || results.Err() != nil {
|
if err != nil || results.Err() != nil {
|
||||||
return fmt.Errorf("can't get key-value pairs from DB: %w", err)
|
return fmt.Errorf("can't get key-value pairs from DB: %w", err)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -10,7 +11,7 @@ import (
|
||||||
|
|
||||||
func getEnvVar(value reflect.Value, rtype reflect.Type, counter int, prefix string) error {
|
func getEnvVar(value reflect.Value, rtype reflect.Type, counter int, prefix string) error {
|
||||||
if value.Kind() != reflect.Ptr {
|
if value.Kind() != reflect.Ptr {
|
||||||
return fmt.Errorf("not a pointer value")
|
return errors.New("not a pointer value")
|
||||||
}
|
}
|
||||||
f := reflect.StructField{}
|
f := reflect.StructField{}
|
||||||
if counter != -1 {
|
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 {
|
func parseToStruct(value reflect.Value, rtype reflect.Type, counter int, prefix string, index map[string]string) error {
|
||||||
if value.Kind() != reflect.Ptr {
|
if value.Kind() != reflect.Ptr {
|
||||||
return fmt.Errorf("not a pointer value")
|
return errors.New("not a pointer value")
|
||||||
}
|
}
|
||||||
f := reflect.StructField{}
|
f := reflect.StructField{}
|
||||||
if counter != -1 {
|
if counter != -1 {
|
||||||
|
|
|
@ -71,6 +71,5 @@ func (l *Logger) Errorf(format string, args ...interface{}) {
|
||||||
|
|
||||||
func (l *Logger) Fatalf(format string, args ...interface{}) {
|
func (l *Logger) Fatalf(format string, args ...interface{}) {
|
||||||
l.Logger.Fatalf(format, args)
|
l.Logger.Fatalf(format, args)
|
||||||
//nolint:gomnd
|
os.Exit(2) //nolint:mnd
|
||||||
os.Exit(2)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue