Skip to content

Commit

Permalink
Update: add root .golangci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ifooth committed Sep 14, 2023
1 parent 1f9783c commit 2ce0252
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
10 changes: 9 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ linters:
- unused

# custom
- gci
- goconst
- gocyclo
- gofmt
# - goheader
- goheader
- goimports
- gosec
- misspell
Expand All @@ -44,6 +45,13 @@ linters-settings:
check-shadowing: true
gocyclo:
min-complexity: 30
goimports:
local-prefixes: github.com/ifooth/devcontainer
gci:
sections:
- standard
- default
- prefix(github.com/ifooth/devcontainer)
gosec:
includes:
- G201 # SQL query construction using format string
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ COPY install-*.sh /usr/local/bin/

# 配置文件
COPY root /opt/root
COPY .golangci.yml /opt/root/.golangci.yml

# 安装依赖包
RUN /usr/local/bin/install-pkg.sh
Expand Down
75 changes: 75 additions & 0 deletions root/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
run:
timeout: 5m

issues:
# 显示所有 issue
max-issues-per-linter: 0
max-same-issues: 0
exclude-use-default: false

linters:
disable-all: true
enable:
# enable by default
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused

# custom
# - gci
- goconst
- gocyclo
- gofmt
- goheader
- goimports
- gosec
- misspell
- nakedret
- revive
- unconvert
- unparam

linters-settings:
# 只开启特定的规则
errcheck:
exclude-functions:
- (*os.File).Close
- (io.Closer).Close
- (net/http.ResponseWriter).Write
- io.Copy
- os.RemoveAll
govet:
check-shadowing: true
gocyclo:
min-complexity: 30
# goimports:
# local-prefixes: github.com/ifooth/devcontainer
# gci:
# sections:
# - standard
# - default
# - prefix(github.com/ifooth/devcontainer)
gosec:
includes:
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G101 # Look for hard coded credentials
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G504 # Import blocklist: net/http/cgi
misspell:
locale: US

revive:
rules:
- name: exported
severity: warning
disabled: false
arguments:
- checkPrivateReceivers
- sayRepetitiveInsteadOfStutters

0 comments on commit 2ce0252

Please sign in to comment.