-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/lint #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Feat/lint #4
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,60 @@ | ||
| name: deploy | ||
| name: Lint & Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Create cache directories | ||
| run: | | ||
| mkdir -p ~/.cache/golangci-lint | ||
| mkdir -p ~/.cache/go-build | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Go Lint Cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/golangci-lint/ | ||
| key: go-lint-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: | | ||
| go-lint-cache-${{ runner.os }}- | ||
|
|
||
| - name: Go Mod Cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cache/go-build | ||
| key: go-mod-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} | ||
| restore-keys: | | ||
| go-mod-cache-${{ runner.os }}- | ||
|
|
||
| - name: Debug Cache Path | ||
| run: | | ||
| ls -la ~/.cache/golangci-lint/ || echo "golangci cache path does not exist" | ||
| ls -la ~/.cache/go-build || echo "go-build cache path does not exist" | ||
|
|
||
| - name: Check go mod | ||
| run: | | ||
| go env | ||
| go mod tidy | ||
| git diff --exit-code go.mod | ||
| git diff --exit-code go.sum | ||
|
|
||
| - name: golangci-lint | ||
| uses: golangci/golangci-lint-action@v8 | ||
| with: | ||
| args: --timeout=10m --verbose | ||
| skip-cache: false | ||
| env: | ||
| GOLANGCI_LINT_CACHE: go-lint-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| version: "2" | ||
| issues: | ||
| fix: true | ||
| linters: | ||
| default: none | ||
| enable: | ||
| - govet | ||
| exclusions: | ||
| presets: | ||
| - comments | ||
| - common-false-positives | ||
| - legacy | ||
| - std-error-handling | ||
| paths: | ||
| - internal/example | ||
| - cmds | ||
| - vendor | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
| formatters: | ||
| enable: | ||
| - goimports | ||
| - gofmt | ||
| - gofumpt | ||
| settings: | ||
| gofumpt: | ||
| extra-rules: true | ||
| goimports: | ||
| # A list of prefixes, which, if set, checks import paths | ||
| # with the given prefixes are grouped after 3rd-party packages. | ||
| # Default: [] | ||
| local-prefixes: | ||
| - github.com/pubgo/opendoc | ||
| gofmt: | ||
| # Simplify code: gofmt with `-s` option. | ||
| # Default: true | ||
| simplify: false | ||
| # Apply the rewrite rules to the source before reformatting. | ||
| # https://pkg.go.dev/cmd/gofmt | ||
| # Default: [] | ||
| rewrite-rules: | ||
| - pattern: 'interface{}' | ||
| replacement: 'any' | ||
| - pattern: 'a[b:len(a)]' | ||
| replacement: 'a[b:]' | ||
|
|
||
| exclusions: | ||
| paths: | ||
| - internal/example | ||
| - vendor | ||
| - examples$ | ||
| - proto | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| v0.1.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你好,感谢你添加了
golangci-lint的支持!这是一个很好的改进。不过,目前只启用了
govet这一个 linter。为了更好地保证代码质量和发现潜在问题,我建议启用更多有用的 linter。例如:staticcheck: 一个强大的静态分析工具集,可以发现很多细微的 bug。unused: 检查未使用的代码。ineffassign: 检查未使用的变量赋值。errcheck: 检查未处理的 error 返回值。gofumpt: 确保代码格式一致。启用这些 linter 可以帮助我们更早地发现问题,提升代码的健壮性。