Skip to content

Commit

Permalink
extend lint checking
Browse files Browse the repository at this point in the history
This is the lint.yaml from logr with better GitHub integration and more checks
enabled.
  • Loading branch information
pohly authored and thockin committed Aug 24, 2021
1 parent b4c0c05 commit 6e71054
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
46 changes: 30 additions & 16 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,37 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
run: |
docker run --rm -v `pwd`:/go/src/prj -w /go/src/prj \
golangci/golangci-lint golangci-lint run \
-v \
--disable-all \
-E deadcode \
-E gocritic \
-E gofmt \
-E govet \
-E ineffassign \
-E misspell \
-E revive \
-E staticcheck \
-E unused \
uses: golangci/golangci-lint-action@v2
with:
# version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# golangci-lint command line arguments.
args:
-v
--max-same-issues 10
--disable-all
--exclude-use-default=false
-E asciicheck
-E deadcode
-E errcheck
-E forcetypeassert
-E gocritic
-E gofmt
-E goimports
-E gosimple
-E govet
-E ineffassign
-E misspell
-E revive
-E staticcheck
-E structcheck
-E typecheck
-E unused
-E varcheck
10 changes: 5 additions & 5 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"go.uber.org/zap"
)

type E struct {
type e struct {
str string
}

func (e E) Error() string {
func (e e) Error() string {
return e.str
}

func Helper(log logr.Logger, msg string) {
func helper(log logr.Logger, msg string) {
helper2(log, msg)
}

Expand All @@ -54,6 +54,6 @@ func example(log logr.Logger) {
log.V(1).Info("you should see this")
log.V(1).V(1).Info("you should NOT see this")
log.Error(nil, "uh oh", "trouble", true, "reasons", []float64{0.1, 0.11, 3.14})
log.Error(E{"an error occurred"}, "goodbye", "code", -1)
Helper(log, "thru a helper")
log.Error(e{"an error occurred"}, "goodbye", "code", -1)
helper(log, "thru a helper")
}
2 changes: 1 addition & 1 deletion zapr.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ limitations under the License.
// See the License for the specific language governing permissions and
// limitations under the License.

// package zapr defines an implementation of the github.com/go-logr/logr
// Package zapr defines an implementation of the github.com/go-logr/logr
// interfaces built on top of Zap (go.uber.org/zap).
//
// Usage
Expand Down

0 comments on commit 6e71054

Please sign in to comment.