Skip to content

Commit dc94741

Browse files
feat: added golint to pipeline
1 parent 77a9e4b commit dc94741

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

.github/workflows/golangci-lint.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
pull_request:
8+
types: [opened, edited, synchronize, reopened]
9+
10+
permissions:
11+
contents: read
12+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
13+
pull-requests: read
14+
15+
# cancel the in-progress workflow when PR is refreshed.
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
18+
cancel-in-progress: true
19+
20+
21+
jobs:
22+
golangci:
23+
name: lint
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
working-directory:
29+
- echo-sql
30+
- gin-mongo
31+
- gin-redis
32+
- graphql-sql
33+
- mux-sql
34+
- S3-Keploy
35+
- sse-svelte
36+
- users-profile
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
- uses: actions/setup-go@v4
41+
with:
42+
go-version: '1.21'
43+
cache: false
44+
- name: golangci-lint
45+
uses: golangci/golangci-lint-action@v3
46+
with:
47+
# Require: The version of golangci-lint to use.
48+
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
49+
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
50+
version: v1.54
51+
52+
# Optional: working directory, useful for monorepos
53+
working-directory: ${{matrix.working-directory}}
54+
55+
# Optional: show only new issues if it's a pull request. The default value is `false`.
56+
only-new-issues: true
57+
58+
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
59+
install-mode: "goinstall"

.golangci.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This is the configuration for golangci-lint for the restic project.
2+
#
3+
# A sample config with all settings is here:
4+
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
5+
6+
linters:
7+
# only enable the linters listed below
8+
disable-all: true
9+
enable:
10+
# make sure all errors returned by functions are handled
11+
- errcheck
12+
13+
# find unused code
14+
- deadcode
15+
16+
# show how code can be simplified
17+
- gosimple
18+
19+
# # make sure code is formatted
20+
- gofmt
21+
22+
# examine code and report suspicious constructs, such as Printf calls whose
23+
# arguments do not align with the format string
24+
- govet
25+
26+
# make sure names and comments are used according to the conventions
27+
- revive
28+
29+
# detect when assignments to existing variables are not used
30+
- ineffassign
31+
32+
# run static analysis and find errors
33+
- staticcheck
34+
35+
# find unused variables, functions, structs, types, etc.
36+
- unused
37+
38+
# find unused struct fields
39+
- structcheck
40+
41+
# find unused global variables
42+
- varcheck
43+
44+
# parse and typecheck code
45+
- typecheck
46+
47+
issues:
48+
# don't use the default exclude rules, this hides (among others) ignored
49+
# errors from Close() calls
50+
exclude-use-default: false
51+
52+
# list of things to not warn about
53+
exclude:
54+
# revive: do not warn about missing comments for exported stuff
55+
- exported (function|method|var|type|const) .* should have comment or be unexported
56+
# revive: ignore constants in all caps
57+
- don't use ALL_CAPS in Go names; use CamelCase

0 commit comments

Comments
 (0)