Skip to content

Commit 48809df

Browse files
committed
fix: Lint error and update English Readme
--story=1
1 parent d872406 commit 48809df

36 files changed

Lines changed: 1732 additions & 1648 deletions

.golangci.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# 完整版本在 https://golangci-lint.run/usage/configuration/
2+
linters-settings:
3+
funlen:
4+
lines: 80
5+
statements: 80
6+
goconst:
7+
min-len: 2
8+
min-occurrences: 2
9+
gocyclo:
10+
min-complexity: 20
11+
goimports:
12+
#local-prefixes: git.code.oa.com,git.woa.com
13+
revive:
14+
confidence: 0
15+
rules:
16+
- name: var-declaration
17+
- name: package-comments
18+
- name: dot-imports
19+
- name: blank-imports
20+
- name: exported
21+
- name: var-naming
22+
- name: indent-error-flow
23+
- name: range
24+
- name: errorf
25+
- name: error-naming
26+
- name: error-strings
27+
- name: receiver-naming
28+
- name: increment-decrement
29+
- name: error-return
30+
#- name: unexported-return
31+
- name: time-naming
32+
- name: context-keys-type
33+
- name: context-as-argument
34+
- name: filename-format
35+
arguments: ["^[_a-z][_a-z0-9]*\\.go$"]
36+
govet:
37+
enable:
38+
- shadow
39+
lll:
40+
line-length: 120
41+
errcheck:
42+
check-type-assertions: true
43+
gocritic:
44+
enabled-checks:
45+
- nestingReduce
46+
settings:
47+
nestingReduce:
48+
bodyWidth: 5
49+
50+
linters:
51+
disable-all: true
52+
enable:
53+
- funlen
54+
- goconst
55+
- gocyclo
56+
- gofmt
57+
- ineffassign
58+
- staticcheck
59+
- typecheck
60+
- goimports
61+
- revive
62+
- gosimple
63+
- govet
64+
- lll
65+
- rowserrcheck
66+
# - errcheck
67+
- unused
68+
- sqlclosecheck
69+
- gocritic
70+
# - bodyclose https://github.com/timakin/bodyclose/issues 问题太多了,屏蔽都屏蔽不过来,显式不使用它
71+
72+
run:
73+
timeout: 20m
74+
75+
issues:
76+
exclude-use-default: true
77+
78+
# The list of ids of default excludes to include or disable. By default it's empty.
79+
# 下面的规则,golangci-lint认为应该屏蔽,但是我们选择不屏蔽。所以,`exclude-use-default: true`屏蔽一部分,把下面的再捞出来。
80+
# golanglint-ci维护的忽略列表里有一些是我们不想屏蔽的,捞出来。这里说一下,使用白名单是好于黑名单的。名单随着golanglint-ci引入更多工具,我们跟进享受好处。我们搞黑名单,就变成自己维护,不如golanglint-ci去维护,更好。
81+
include:
82+
- EXC0004 # govet (possible misuse of unsafe.Pointer|should have signature)
83+
- EXC0005 # staticcheck ineffective break statement. Did you mean to break out of the outer loop
84+
- EXC0012 # revive exported (method|function|type|const) (.+) should have comment or be unexported
85+
- EXC0013 # revive package comment should be of the form "(.+)...
86+
- EXC0014 # revive comment on exported (.+) should be of the form "(.+)..."
87+
- EXC0015 # revive should have a package comment, unless it's in another file for this package
88+
89+
exclude-rules:
90+
- path: _test\.go
91+
linters:
92+
- funlen # 规范说单测函数,单个函数可以到160行,但是工具不好做区分处理,这里就直接不检查单测的函数长度
93+
- linters:
94+
- staticcheck
95+
text: "SA6002: argument should be pointer-like to avoid allocations" # sync.pool.Put(buf), slice `var buf []byte` will tiger this
96+
- linters:
97+
- lll
98+
source: "^//go:generate " # Exclude lll issues for long lines with go:generate
99+
100+
max-same-issues: 0
101+
new: false
102+
max-issues-per-linter: 0
103+
104+
output:
105+
sort-results: true
106+
107+

0 commit comments

Comments
 (0)