mirror of https://github.com/zhufuyi/sponge
style: adjustment code
This commit is contained in:
parent
967013cc51
commit
fdb83e6fd1
|
@ -3,7 +3,6 @@
|
|||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
*.log
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
|
|
|
@ -56,7 +56,7 @@ linters:
|
|||
- unconvert
|
||||
- whitespace
|
||||
- staticcheck
|
||||
#- bodyclose
|
||||
- bodyclose
|
||||
#- dupl
|
||||
#- goprintffuncname
|
||||
#- gosec
|
||||
|
@ -67,6 +67,8 @@ linters:
|
|||
linters-settings:
|
||||
revive:
|
||||
rules:
|
||||
- name: indent-error-flow
|
||||
- name: unused-parameter
|
||||
- name: argument-limit
|
||||
arguments: [ 8 ]
|
||||
- name: atomic
|
||||
|
@ -96,7 +98,6 @@ linters-settings:
|
|||
- name: if-return
|
||||
- name: import-shadowing
|
||||
- name: increment-decrement
|
||||
- name: indent-error-flow
|
||||
- name: modifies-parameter
|
||||
- name: modifies-value-receiver
|
||||
- name: package-comments
|
||||
|
@ -113,7 +114,6 @@ linters-settings:
|
|||
- name: unexported-naming
|
||||
- name: unnecessary-stmt
|
||||
- name: unreachable-code
|
||||
- name: unused-parameter
|
||||
- name: var-declaration
|
||||
- name: var-naming
|
||||
- name: waitgroup-by-value
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 zhuyasen
|
||||
Copyright (c) 2022 zhufuyi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -6,6 +6,7 @@ package merge
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -112,7 +113,7 @@ func (m *mergeParam) runMergeCode(file string) (string, error) {
|
|||
count1 := bytes.Count(data1, m.splitLineMark)
|
||||
count2 := bytes.Count(data2, m.splitLineMark)
|
||||
if count1 != count2 {
|
||||
return "", fmt.Errorf(color.RedString("merge code failed (%s --> %s), manually merge code"+
|
||||
return "", errors.New(color.RedString("merge code failed (%s --> %s), manually merge code"+
|
||||
" reference document https://github.com/zhufuyi/sponge/tree/main/cmd/sponge/commands/merge",
|
||||
cutPathPrefix(file), getTargetFilename(file)))
|
||||
}
|
||||
|
@ -135,7 +136,7 @@ func (m *mergeParam) runMergeCode(file string) (string, error) {
|
|||
}
|
||||
|
||||
if len(data1) > len(data) {
|
||||
return "", fmt.Errorf(color.RedString("merge code failed (%s --> %s), to avoid replacing logical code, "+
|
||||
return "", errors.New(color.RedString("merge code failed (%s --> %s), to avoid replacing logical code, "+
|
||||
"manually merge code reference document https://github.com/zhufuyi/sponge/tree/main/cmd/sponge/commands/merge",
|
||||
cutPathPrefix(file), getTargetFilename(file)))
|
||||
}
|
||||
|
|
|
@ -13,12 +13,12 @@ type Group struct {
|
|||
}
|
||||
|
||||
// NewGroup news a group container.
|
||||
func NewGroup(new func() interface{}) *Group {
|
||||
if new == nil {
|
||||
func NewGroup(fn func() interface{}) *Group {
|
||||
if fn == nil {
|
||||
panic("container.group: can't assign a nil to the new function")
|
||||
}
|
||||
return &Group{
|
||||
new: new,
|
||||
new: fn,
|
||||
vals: make(map[string]interface{}),
|
||||
}
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ func (g *Group) Get(key string) interface{} {
|
|||
}
|
||||
|
||||
// Reset resets the new function and deletes all existing objects.
|
||||
func (g *Group) Reset(new func() interface{}) {
|
||||
if new == nil {
|
||||
func (g *Group) Reset(fn func() interface{}) {
|
||||
if fn == nil {
|
||||
panic("container.group: can't assign a nil to the new function")
|
||||
}
|
||||
g.Lock()
|
||||
g.new = new
|
||||
g.new = fn
|
||||
g.Unlock()
|
||||
g.Clear()
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ func getSQL(args *Args) (string, map[string]string, error) {
|
|||
sqlStr, mongoTypeMap := parser.ConvertToSQLByMgoFields(args.DBTable, fields)
|
||||
return sqlStr, mongoTypeMap, nil
|
||||
default:
|
||||
return "", nil, fmt.Errorf("getsql error, unsupported database driver: " + dbDriverName)
|
||||
return "", nil, errors.New("get sql error, unsupported database driver: " + dbDriverName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,9 @@ func (p *WaitPrinter) StopPrint(tip string) {
|
|||
}
|
||||
|
||||
defer func() {
|
||||
recover()
|
||||
if e := recover(); e != nil {
|
||||
fmt.Println(e)
|
||||
}
|
||||
}()
|
||||
|
||||
p.cancel()
|
||||
|
|
Loading…
Reference in New Issue