Skip to content

Commit fdb83e6

Browse files
committed
style: adjustment code
1 parent 967013c commit fdb83e6

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*.exe~
44
*.dll
55
*.so
6-
*.dylib
76
*.log
87

98
# Test binary, built with `go test -c`

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ linters:
5656
- unconvert
5757
- whitespace
5858
- staticcheck
59-
#- bodyclose
59+
- bodyclose
6060
#- dupl
6161
#- goprintffuncname
6262
#- gosec
@@ -67,6 +67,8 @@ linters:
6767
linters-settings:
6868
revive:
6969
rules:
70+
- name: indent-error-flow
71+
- name: unused-parameter
7072
- name: argument-limit
7173
arguments: [ 8 ]
7274
- name: atomic
@@ -96,7 +98,6 @@ linters-settings:
9698
- name: if-return
9799
- name: import-shadowing
98100
- name: increment-decrement
99-
- name: indent-error-flow
100101
- name: modifies-parameter
101102
- name: modifies-value-receiver
102103
- name: package-comments
@@ -113,7 +114,6 @@ linters-settings:
113114
- name: unexported-naming
114115
- name: unnecessary-stmt
115116
- name: unreachable-code
116-
- name: unused-parameter
117117
- name: var-declaration
118118
- name: var-naming
119119
- name: waitgroup-by-value

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 zhuyasen
3+
Copyright (c) 2022 zhufuyi
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

cmd/sponge/commands/merge/common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package merge
66
import (
77
"bufio"
88
"bytes"
9+
"errors"
910
"fmt"
1011
"os"
1112
"path"
@@ -112,7 +113,7 @@ func (m *mergeParam) runMergeCode(file string) (string, error) {
112113
count1 := bytes.Count(data1, m.splitLineMark)
113114
count2 := bytes.Count(data2, m.splitLineMark)
114115
if count1 != count2 {
115-
return "", fmt.Errorf(color.RedString("merge code failed (%s --> %s), manually merge code"+
116+
return "", errors.New(color.RedString("merge code failed (%s --> %s), manually merge code"+
116117
" reference document https://github.com/zhufuyi/sponge/tree/main/cmd/sponge/commands/merge",
117118
cutPathPrefix(file), getTargetFilename(file)))
118119
}
@@ -135,7 +136,7 @@ func (m *mergeParam) runMergeCode(file string) (string, error) {
135136
}
136137

137138
if len(data1) > len(data) {
138-
return "", fmt.Errorf(color.RedString("merge code failed (%s --> %s), to avoid replacing logical code, "+
139+
return "", errors.New(color.RedString("merge code failed (%s --> %s), to avoid replacing logical code, "+
139140
"manually merge code reference document https://github.com/zhufuyi/sponge/tree/main/cmd/sponge/commands/merge",
140141
cutPathPrefix(file), getTargetFilename(file)))
141142
}

pkg/container/group/group.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ type Group struct {
1313
}
1414

1515
// NewGroup news a group container.
16-
func NewGroup(new func() interface{}) *Group {
17-
if new == nil {
16+
func NewGroup(fn func() interface{}) *Group {
17+
if fn == nil {
1818
panic("container.group: can't assign a nil to the new function")
1919
}
2020
return &Group{
21-
new: new,
21+
new: fn,
2222
vals: make(map[string]interface{}),
2323
}
2424
}
@@ -46,12 +46,12 @@ func (g *Group) Get(key string) interface{} {
4646
}
4747

4848
// Reset resets the new function and deletes all existing objects.
49-
func (g *Group) Reset(new func() interface{}) {
50-
if new == nil {
49+
func (g *Group) Reset(fn func() interface{}) {
50+
if fn == nil {
5151
panic("container.group: can't assign a nil to the new function")
5252
}
5353
g.Lock()
54-
g.new = new
54+
g.new = fn
5555
g.Unlock()
5656
g.Clear()
5757
}

pkg/sql2code/sql2code.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func getSQL(args *Args) (string, map[string]string, error) {
116116
sqlStr, mongoTypeMap := parser.ConvertToSQLByMgoFields(args.DBTable, fields)
117117
return sqlStr, mongoTypeMap, nil
118118
default:
119-
return "", nil, fmt.Errorf("getsql error, unsupported database driver: " + dbDriverName)
119+
return "", nil, errors.New("get sql error, unsupported database driver: " + dbDriverName)
120120
}
121121
}
122122

pkg/utils/wait_print.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ func (p *WaitPrinter) StopPrint(tip string) {
6363
}
6464

6565
defer func() {
66-
recover()
66+
if e := recover(); e != nil {
67+
fmt.Println(e)
68+
}
6769
}()
6870

6971
p.cancel()

0 commit comments

Comments
 (0)