chore: fix lint
parent
387fef2780
commit
ef06378dbd
|
@ -19,12 +19,15 @@ linters:
|
||||||
- errcheck
|
- errcheck
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
|
- ineffassign
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- typecheck
|
- typecheck
|
||||||
- unused
|
- unused
|
||||||
|
- errchkjson
|
||||||
- errname
|
- errname
|
||||||
- errorlint
|
- errorlint
|
||||||
- execinquery
|
- execinquery
|
||||||
|
- gocritic
|
||||||
- goerr113
|
- goerr113
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- gosec
|
- gosec
|
||||||
|
@ -38,7 +41,10 @@ linters:
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gosec:
|
gosec:
|
||||||
excludes:
|
excludes:
|
||||||
|
- G101
|
||||||
|
- G112
|
||||||
- G402
|
- G402
|
||||||
|
- G404
|
||||||
- G501
|
- G501
|
||||||
- G505
|
- G505
|
||||||
exclude-generated: true
|
exclude-generated: true
|
||||||
|
@ -63,3 +69,7 @@ linters-settings:
|
||||||
- unusedresult
|
- unusedresult
|
||||||
staticcheck:
|
staticcheck:
|
||||||
checks: ["all", "-SA1019"]
|
checks: ["all", "-SA1019"]
|
||||||
|
gocritic:
|
||||||
|
enabled-tags:
|
||||||
|
- style
|
||||||
|
- performance
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -1,11 +1,32 @@
|
||||||
.PHONY: all test-color lint
|
.PHONY: all test test-color coverage coverage-cli coverate-html lint format build
|
||||||
|
|
||||||
all: test-color lint
|
all: test-color lint format
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
|
||||||
|
test:
|
||||||
|
go test -race -failfast ./...
|
||||||
|
|
||||||
test-color:
|
test-color:
|
||||||
go install github.com/haunt98/go-test-color@latest
|
go install github.com/haunt98/go-test-color@latest
|
||||||
go-test-color -race -failfast ./...
|
go-test-color -race -failfast ./...
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
go test -coverprofile=coverage.out ./...
|
||||||
|
|
||||||
|
coverage-cli: coverage
|
||||||
|
go tool cover -func=coverage.out
|
||||||
|
|
||||||
|
coverage-html: coverage
|
||||||
|
go tool cover -html=coverage.out
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
golangci-lint run ./...
|
golangci-lint run ./...
|
||||||
|
|
||||||
|
format:
|
||||||
|
go install github.com/haunt98/gofimports/cmd/gofimports@latest
|
||||||
|
go install mvdan.cc/gofumpt@latest
|
||||||
|
gofimports -w -company github.com/make-go-great .
|
||||||
|
gofumpt -w -extra .
|
||||||
|
|
||||||
|
build:
|
||||||
|
go build ./cmd/populatedb
|
||||||
|
|
|
@ -3,8 +3,9 @@ package cli
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/haunt98/populatedb-go/internal/populatedb"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"github.com/haunt98/populatedb-go/internal/populatedb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *action) RunGenerate(c *cli.Context) error {
|
func (a *action) RunGenerate(c *cli.Context) error {
|
||||||
|
|
|
@ -3,8 +3,9 @@ package cli
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/make-go-great/color-go"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"github.com/make-go-great/color-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -215,15 +215,15 @@ func (p *populator) InsertBatch(ctx context.Context, tableName string, numberRec
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return columnNames, questionMarks, argFns
|
// Return columnNames, questionMarks, argFns
|
||||||
func (p *populator) prepareInsert(tableName string) ([]string, []string, []func() any, error) {
|
func (p *populator) prepareInsert(tableName string) (columnNames, questionMarks []string, argFns []func() any, err error) {
|
||||||
table, ok := p.tables[tableName]
|
table, ok := p.tables[tableName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, nil, fmt.Errorf("table [%s] not exist: %w", tableName, ErrTableNotExist)
|
return nil, nil, nil, fmt.Errorf("table [%s] not exist: %w", tableName, ErrTableNotExist)
|
||||||
}
|
}
|
||||||
|
|
||||||
columnNames := make([]string, 0, len(table.Columns))
|
columnNames = make([]string, 0, len(table.Columns))
|
||||||
questionMarks := make([]string, 0, len(table.Columns))
|
questionMarks = make([]string, 0, len(table.Columns))
|
||||||
argFns := make([]func() any, 0, len(table.Columns))
|
argFns = make([]func() any, 0, len(table.Columns))
|
||||||
for _, column := range table.Columns {
|
for _, column := range table.Columns {
|
||||||
dt, err := ParseDatabaseType(column)
|
dt, err := ParseDatabaseType(column)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue