Skip to content

Commit cfc79af

Browse files
authored
Merge pull request #40 from matsuri-tech/feat/lint-and-format
feat: lint and format
2 parents e1e00df + 00b4533 commit cfc79af

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: golang-ci-lint
2+
on:
3+
push:
4+
branches:
5+
# デフォルトブランチに合わせて変更
6+
- master
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
jobs:
12+
golangci:
13+
name: lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version-file: "./go.mod"
20+
cache: true
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v4
23+
with:
24+
version: latest
25+
args: --config=.golangci.yml -v --timeout 10m

.golangci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
linters:
2+
# disable-all: true
3+
enable:
4+
- gofumpt
5+
- durationcheck
6+
- forcetypeassert
7+
# TODO: そのうち入れたいlinterのオプション
8+
# - gocognit
9+
# - goconst
10+
# - gocritic
11+
# - disabled-checks:
12+
# - captLocal
13+
# - gochecknoglobals
14+
# - errorlint
15+
# - exhaustive
16+
# - funlen
17+
issues:
18+
max-same-issues: 0
19+
exclude-rules:
20+
# Exclude some linters from running on tests files.
21+
- path: _test\.go
22+
linters:
23+
- forcetypeassert

endpoints.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"github.com/invopop/jsonschema"
87
"io"
98
"net/http"
109
"os"
1110
"strings"
1211

12+
"github.com/invopop/jsonschema"
13+
1314
"github.com/getkin/kin-openapi/openapi3"
1415
"gopkg.in/yaml.v3"
1516

endpoints_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package endpoints
33
import (
44
"bytes"
55
"encoding/json"
6+
"testing"
7+
68
"github.com/labstack/echo/v4"
79
"github.com/stretchr/testify/assert"
8-
"testing"
910
)
1011

1112
type SampleModel struct {

wrapper.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package endpoints
22

33
import (
4-
"github.com/labstack/echo/v4"
54
"net/http"
65
"os"
6+
7+
"github.com/labstack/echo/v4"
78
)
89

910
// EchoWrapper に対応するメソッドが存在しないEchoの機能を使いたい場合に限り、
@@ -77,7 +78,7 @@ func (w *EchoWrapper) Generate(filename string) error {
7778
}
7879

7980
func (w *EchoWrapper) GenerateOpenApiJson(filename string, config OpenApiGeneratorConfig) error {
80-
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
81+
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
8182
if err != nil {
8283
return err
8384
}
@@ -89,7 +90,7 @@ func (w *EchoWrapper) GenerateOpenApiJson(filename string, config OpenApiGenerat
8990
}
9091

9192
func (w *EchoWrapper) GenerateOpenApi(filename string, config OpenApiGeneratorConfig) error {
92-
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
93+
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
9394
if err != nil {
9495
return err
9596
}

0 commit comments

Comments
 (0)