timehelper/基于golangci-lint修改代码;
This commit is contained in:
138
timehelper/.golangci.yaml
Normal file
138
timehelper/.golangci.yaml
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
## 更新到 golangci-lint@v1.52.2
|
||||||
|
run:
|
||||||
|
timeout: 1m
|
||||||
|
build-tags: [ ]
|
||||||
|
skip-dirs: [ ]
|
||||||
|
skip-files: [ ]
|
||||||
|
linters:
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- errcheck
|
||||||
|
- gosimple
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- staticcheck
|
||||||
|
- typecheck
|
||||||
|
- unused
|
||||||
|
- asasalint
|
||||||
|
- asciicheck
|
||||||
|
- bidichk
|
||||||
|
- bodyclose
|
||||||
|
- containedctx
|
||||||
|
- cyclop
|
||||||
|
- dupl
|
||||||
|
- durationcheck
|
||||||
|
- errname
|
||||||
|
- errorlint
|
||||||
|
- exhaustive
|
||||||
|
- exportloopref
|
||||||
|
- funlen
|
||||||
|
- gocheckcompilerdirectives
|
||||||
|
- gochecknoinits
|
||||||
|
- goconst
|
||||||
|
- gocritic
|
||||||
|
- gocyclo
|
||||||
|
- goimports
|
||||||
|
- gomnd
|
||||||
|
- goprintffuncname
|
||||||
|
- gosec
|
||||||
|
- lll
|
||||||
|
- loggercheck
|
||||||
|
- makezero
|
||||||
|
- nakedret
|
||||||
|
- nestif
|
||||||
|
- nilnil
|
||||||
|
- noctx
|
||||||
|
- nolintlint
|
||||||
|
- nosprintfhostport
|
||||||
|
- prealloc
|
||||||
|
- predeclared
|
||||||
|
- promlinter
|
||||||
|
- reassign
|
||||||
|
- revive
|
||||||
|
- stylecheck
|
||||||
|
- tenv
|
||||||
|
- testableexamples
|
||||||
|
- testpackage
|
||||||
|
- tparallel
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- usestdlibvars
|
||||||
|
- wastedassign
|
||||||
|
- whitespace
|
||||||
|
linters-settings:
|
||||||
|
errcheck:
|
||||||
|
check-type-assertions: true
|
||||||
|
exclude-functions: [ ]
|
||||||
|
govet:
|
||||||
|
enable-all: true
|
||||||
|
disable: [ ]
|
||||||
|
cyclop:
|
||||||
|
max-complexity: 10
|
||||||
|
package-average: 0.0
|
||||||
|
dupl:
|
||||||
|
threshold: 150
|
||||||
|
exhaustive:
|
||||||
|
check:
|
||||||
|
- switch
|
||||||
|
- map
|
||||||
|
funlen:
|
||||||
|
lines: 100
|
||||||
|
statements: 60
|
||||||
|
gocritic:
|
||||||
|
disabled-checks:
|
||||||
|
- commentFormatting
|
||||||
|
settings:
|
||||||
|
captLocal:
|
||||||
|
paramsOnly: false
|
||||||
|
underef:
|
||||||
|
skipRecvDeref: false
|
||||||
|
gocyclo:
|
||||||
|
min-complexity: 20
|
||||||
|
gomnd:
|
||||||
|
ignored-functions:
|
||||||
|
- os.Chmod
|
||||||
|
- os.Mkdir
|
||||||
|
- os.MkdirAll
|
||||||
|
- os.OpenFile
|
||||||
|
- os.WriteFile
|
||||||
|
- prometheus.ExponentialBuckets
|
||||||
|
- prometheus.ExponentialBucketsRange
|
||||||
|
- prometheus.LinearBuckets
|
||||||
|
lll:
|
||||||
|
line-length: 240
|
||||||
|
nakedret:
|
||||||
|
max-func-lines: 10
|
||||||
|
nestif:
|
||||||
|
min-complexity: 5
|
||||||
|
predeclared:
|
||||||
|
ignore: ""
|
||||||
|
q: false
|
||||||
|
reassign:
|
||||||
|
patterns:
|
||||||
|
- ".*"
|
||||||
|
tenv:
|
||||||
|
all: true
|
||||||
|
usestdlibvars:
|
||||||
|
time-month: true
|
||||||
|
time-layout: true
|
||||||
|
crypto-hash: true
|
||||||
|
default-rpc-path: true
|
||||||
|
os-dev-null: true
|
||||||
|
sql-isolation-level: true
|
||||||
|
tls-signature-scheme: true
|
||||||
|
constant-kind: true
|
||||||
|
syslog-priority: true
|
||||||
|
issues:
|
||||||
|
max-same-issues: 10
|
||||||
|
exclude-rules:
|
||||||
|
- source: "//noinspection"
|
||||||
|
linters: [ gocritic ]
|
||||||
|
- path: "_test\\.go"
|
||||||
|
linters:
|
||||||
|
- bodyclose
|
||||||
|
- dupl
|
||||||
|
- funlen
|
||||||
|
- goconst
|
||||||
|
- gosec
|
||||||
|
- noctx
|
||||||
@@ -4,5 +4,5 @@ import "time"
|
|||||||
|
|
||||||
// SetupCST 把本地时区固定到CST
|
// SetupCST 把本地时区固定到CST
|
||||||
func SetupCST() {
|
func SetupCST() {
|
||||||
time.Local = time.FixedZone("CST", 8*3600)
|
time.Local = time.FixedZone("CST", 8*3600) //nolint:gomnd,reassign
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,20 +14,20 @@ func ExampleRFC3339Nano() {
|
|||||||
// Output: 2023-01-15T15:16:17.123456789+08:00
|
// Output: 2023-01-15T15:16:17.123456789+08:00
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleRFC3339Nano2Sec() {
|
func ExampleRFC3339_nano2Sec() {
|
||||||
t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T15:16:17.123456789+08:00")
|
t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T15:16:17.123456789+08:00")
|
||||||
fmt.Println(t.Format(time.RFC3339))
|
fmt.Println(t.Format(time.RFC3339))
|
||||||
// Output: 2023-01-15T15:16:17+08:00
|
// Output: 2023-01-15T15:16:17+08:00
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用 RFC3339 没有丢失纳秒精度
|
// 使用 RFC3339 没有丢失纳秒精度
|
||||||
func ExampleRFC3339Sec2Nano() {
|
func ExampleRFC3339_sec2Nano() {
|
||||||
t, _ := time.Parse(time.RFC3339, "2023-01-15T15:16:17.123456789+08:00")
|
t, _ := time.Parse(time.RFC3339, "2023-01-15T15:16:17.123456789+08:00")
|
||||||
fmt.Println(t.Format(time.RFC3339Nano))
|
fmt.Println(t.Format(time.RFC3339Nano))
|
||||||
// Output: 2023-01-15T15:16:17.123456789+08:00
|
// Output: 2023-01-15T15:16:17.123456789+08:00
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleRFC3339NanoOtherZone() {
|
func ExampleRFC3339_nanoOtherZone() {
|
||||||
t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T15:16:17.123456789+09:00")
|
t, _ := time.Parse(time.RFC3339Nano, "2023-01-15T15:16:17.123456789+09:00")
|
||||||
fmt.Println(t.Format(time.RFC3339Nano))
|
fmt.Println(t.Format(time.RFC3339Nano))
|
||||||
// Output: 2023-01-15T15:16:17.123456789+09:00
|
// Output: 2023-01-15T15:16:17.123456789+09:00
|
||||||
|
|||||||
Reference in New Issue
Block a user