Skip to content

Commit

Permalink
Introduce golangci-lint (#77)
Browse files Browse the repository at this point in the history
* Introduce golangci-lint

* Create .golangci.yaml

* Update gobreaker_test.go

* Update gobreaker_test.go

* Update .golangci.yaml
  • Loading branch information
YoshiyukiMineo authored Dec 28, 2024
1 parent 5bd8570 commit 9e2b7bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{matrix.os}}
steps:
- name: Set up Go
uses: actions/setup-go@v2
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{matrix.go-version}}
- name: Checkout
uses: actions/checkout@v2
- name: gofmt
run: test -z "`gofmt -l .`"
- name: golint
run: test -z "`golint ./...`"
uses: actions/checkout@v4
- name: Lint
uses: golangci/golangci-lint-action@v6
- name: go test
run: go test -v ./...
- name: Run example
Expand Down
15 changes: 15 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
linters:
enable:
- gofmt
- goimports
- gosec
- misspell
issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
- govet
- path: example/
linters:
- gosec
6 changes: 3 additions & 3 deletions gobreaker_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gobreaker

import (
"fmt"
"errors"
"runtime"
"testing"
"time"
Expand Down Expand Up @@ -55,7 +55,7 @@ func succeed2Step(cb *TwoStepCircuitBreaker) error {

func fail(cb *CircuitBreaker) error {
msg := "fail"
_, err := cb.Execute(func() (interface{}, error) { return nil, fmt.Errorf(msg) })
_, err := cb.Execute(func() (interface{}, error) { return nil, errors.New(msg) })
if err.Error() == msg {
return nil
}
Expand Down Expand Up @@ -322,7 +322,7 @@ func TestTwoStepCircuitBreaker(t *testing.T) {
}

func TestPanicInRequest(t *testing.T) {
assert.Panics(t, func() { causePanic(defaultCB) })
assert.Panics(t, func() { _ = causePanic(defaultCB) })
assert.Equal(t, Counts{1, 0, 1, 0, 1}, defaultCB.counts)
}

Expand Down

0 comments on commit 9e2b7bf

Please sign in to comment.