Skip to content

Commit 5985209

Browse files
authored
Merge pull request #29 from mudclient/style/lint
排版和重构代码,以提升代码质量
2 parents 7e74b49 + ed5ae3f commit 5985209

File tree

10 files changed

+445
-410
lines changed

10 files changed

+445
-410
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ jobs:
2525

2626
- name: Build
2727
run: go build -v .
28+
29+
- name: Lint
30+
run: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.23.3 golangci-lint run -v ./...

.golangci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
service:
2+
golangci-lint-version: 1.23.x
3+
prepare:
4+
- go mod tidy
5+
- go generate ./...
6+
7+
linters:
8+
enable-all: true
9+
disable:
10+
# 因为只有两行语句的 case 语句里面强制要求 return 语句换行会让整个 switch 很分裂。
11+
- wsl
12+
# 因为连 1 都算 magic number 的话,许多循环就没法写了。
13+
# https://github.com/tommy-muehle/go-mnd/issues/3
14+
- gomnd
15+
# 有些情况下错误不可避免:
16+
# https://github.com/alexkohler/dogsled/issues/2
17+
- dogsled
18+
# V1.0 之前有 TODO/FIXME 很正常吧。
19+
- godox
20+
# 有些情况下错误不可避免:
21+
# https://github.com/mvdan/unparam/issues/43
22+
- unparam
23+
# 下面这两个 checker 太过激进,并不认同
24+
- gochecknoglobals
25+
- gochecknoinits
26+
27+
linters-settings:
28+
errcheck:
29+
check-type-assertions: true
30+
ignore: '[FS]?[Pp]rint(|f|ln)|Write'

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
</a>
1717
<a href="https://github.com/mudclient/go-mud/actions?workflow=Build">
1818
<img alt="Build workflow" src="https://github.com/mudclient/go-mud/workflows/Build/badge.svg">
19+
</a>
20+
<a href="https://goreportcard.com/report/github.com/mudclient/go-mud">
21+
<img alt="Go Report" src="https://goreportcard.com/badge/github.com/mudclient/go-mud">
22+
</a>
23+
<a href="https://golangci.com/r/github.com/mudclient/go-mud">
24+
<img alt="GolangCI Report" src="https://github.com/golangci/golangci-web/blob/master/src/assets/images/badge_a_plus_flat.svg">
1925
</a>
2026
</p>
2127
</p>

0 commit comments

Comments
 (0)