Skip to content

Commit

Permalink
fix: golangci-lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
ken109 committed Nov 23, 2023
1 parent d81270d commit 5e99571
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 28 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Run Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'

- name: Checkout repository
uses: actions/checkout@v4

- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --verbose

test:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'

- name: Checkout Code
uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Tests
run: |
go test ./... -v -covermode=atomic -coverprofile=coverage.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
19 changes: 0 additions & 19 deletions .github/workflows/test.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ func TryVerify(realm string) func(c *gin.Context) {

c.Set("claims", token.PrivateClaims())
c.Next()
return
}
}

Expand Down Expand Up @@ -209,7 +208,6 @@ func MustVerify(realm string) func(c *gin.Context) {

c.Set("claims", token.PrivateClaims())
c.Next()
return
}
}

Expand Down
5 changes: 0 additions & 5 deletions jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,18 @@ func TestMain(m *testing.M) {

if err := jwt.SetUp(jwt.Option{Realm: rsRealm, SigningAlgorithm: jwt.RS256, PrivKeyBytes: privateKeyBytes}); err != nil {
panic(fmt.Errorf("failed to set up: %w", err))
return
}

if err := jwt.SetUp(jwt.Option{Realm: rsRealm2, SigningAlgorithm: jwt.RS256, PrivKeyBytes: privateKeyBytes}); err != nil {
panic(fmt.Errorf("failed to set up: %w", err))
return
}

if err := jwt.SetUp(jwt.Option{Realm: hsRealm, SigningAlgorithm: jwt.HS256, SecretKey: []byte("secret")}); err != nil {
panic(fmt.Errorf("failed to set up: %w", err))
return
}

if err := jwt.SetUp(jwt.Option{Realm: hsRealm2, SigningAlgorithm: jwt.HS256, SecretKey: []byte("secret")}); err != nil {
panic(fmt.Errorf("failed to set up: %w", err))
return
}

if err := jwt.SetUp(
Expand All @@ -70,7 +66,6 @@ func TestMain(m *testing.M) {
},
); err != nil {
panic(fmt.Errorf("failed to set up: %w", err))
return
}

os.Exit(m.Run())
Expand Down
4 changes: 2 additions & 2 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"os"
"time"
)

Expand Down Expand Up @@ -49,7 +49,7 @@ func setRsaPrivateKey(option *Option) error {
if len(option.PrivKeyBytes) > 0 {
privKeyBytes = option.PrivKeyBytes
} else if option.PrivKeyFile != "" {
privKeyBytes, err = ioutil.ReadFile(option.PrivKeyFile)
privKeyBytes, err = os.ReadFile(option.PrivKeyFile)
if err != nil {
return fmt.Errorf("failed to read file: %s", option.PrivKeyFile)
}
Expand Down

0 comments on commit 5e99571

Please sign in to comment.