Skip to content

Commit

Permalink
add golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshiro.maruo committed Mar 15, 2021
1 parent fba30d8 commit a2bc52e
Show file tree
Hide file tree
Showing 10 changed files with 448 additions and 24 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: goreleaser

on:
pull_request:
push:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ master ]

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -19,3 +19,7 @@ jobs:

- name: Test
run: go test -v ./...

- name: Lint
run: golangci-lint run

6 changes: 3 additions & 3 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package cmd
import (
"os"

"github.com/snowhork/rdiam/cmd/impl"

"github.com/snowhork/rdiam/pkg/redash"
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/snowhork/rdiam/cmd/impl"
"github.com/snowhork/rdiam/pkg/redash"
)

func init() {
Expand Down
10 changes: 5 additions & 5 deletions cmd/impl/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func AddCmd(client addRedashClient, users, groups []string) error {
type addRedashClient interface {
SearchUser(q string) ([]byte, error)
GetGroups() ([]byte, error)
AddMember(groupId, userId int) ([]byte, error)
AddMember(groupID, userID int) ([]byte, error)
}

func findGroupID(client addRedashClient, groupName string) (int, error) {
Expand All @@ -68,7 +68,7 @@ func findGroupID(client addRedashClient, groupName string) (int, error) {
}

var resp []struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
Expand All @@ -77,7 +77,7 @@ func findGroupID(client addRedashClient, groupName string) (int, error) {

for _, g := range resp {
if g.Name == groupName {
return g.Id, nil
return g.ID, nil
}
}

Expand All @@ -92,7 +92,7 @@ func findUserID(client addRedashClient, userEmail string) (int, error) {

var resp struct {
Results []struct {
Id int `json:"id"`
ID int `json:"id"`
Email string `json:"email"`
} `json:"results"`
}
Expand All @@ -109,5 +109,5 @@ func findUserID(client addRedashClient, userEmail string) (int, error) {
return -1, xerrors.Errorf("user: %s not found", userEmail)
}

return user.Id, nil
return user.ID, nil
}
18 changes: 9 additions & 9 deletions cmd/impl/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ func getDataSourceIDByQuery(client inspectRedashClient, queryID int) (int, error
}

var resp struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
DataSourceId int `json:"data_source_id"`
DataSourceID int `json:"data_source_id"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
return 0, xerrors.Errorf("json.Unmarshal: %+w", err)
}

return resp.DataSourceId, nil
return resp.DataSourceID, nil
}

func getGroupIDsByDataSource(client inspectRedashClient, dataSourceID int, acceptReadOnly bool) ([]int, error) {
Expand Down Expand Up @@ -144,7 +144,7 @@ func getGroupIDToName(client inspectRedashClient) (map[int]string, error) {
return nil, xerrors.Errorf("client.GetGroups: %+w", err)
}
var resp []struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
Expand All @@ -153,7 +153,7 @@ func getGroupIDToName(client inspectRedashClient) (map[int]string, error) {

res := make(map[int]string)
for _, g := range resp {
res[g.Id] = g.Name
res[g.ID] = g.Name
}

return res, nil
Expand All @@ -169,7 +169,7 @@ func getQueryIDsByDashboard(client inspectRedashClient, dashboardSlug string) ([
Widgets []struct {
Visualization *struct {
Query struct {
Id int `json:"id"`
ID int `json:"id"`
} `json:"query"`
} `json:"visualization"`
} `json:"widgets"`
Expand All @@ -185,7 +185,7 @@ func getQueryIDsByDashboard(client inspectRedashClient, dashboardSlug string) ([
continue
}

ids = append(ids, w.Visualization.Query.Id)
ids = append(ids, w.Visualization.Query.ID)
}

return ids, nil
Expand Down Expand Up @@ -216,7 +216,7 @@ func explainQuery(client inspectRedashClient, queryID int, indent int) error {
}

var resp struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
Expand All @@ -234,7 +234,7 @@ func explainDataSource(client inspectRedashClient, dataSourceID int, indent int)
return xerrors.Errorf("client.GetDataSource: %+w", err)
}
var resp struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
}
if err := json.Unmarshal(raw, &resp); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"os"
"strconv"

"github.com/snowhork/rdiam/cmd/impl"
"github.com/snowhork/rdiam/pkg/redash"
"github.com/spf13/cobra"
"golang.org/x/xerrors"

"github.com/snowhork/rdiam/cmd/impl"
"github.com/snowhork/rdiam/pkg/redash"
)

func init() {
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"os"

"github.com/mitchellh/go-homedir"

"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ go 1.16

require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-lintpack/lintpack v0.5.2 // indirect
github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 // indirect
github.com/golangci/go-tools v0.0.0-20190318055746-e32c54105b7c // indirect
github.com/golangci/goconst v0.0.0-20180610141641-041c5f2b40f3 // indirect
github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee // indirect
github.com/golangci/golangci-lint v1.38.0 // indirect
github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547 // indirect
github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc // indirect
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21 // indirect
github.com/klauspost/cpuid v1.2.0 // indirect
github.com/magiconair/properties v1.8.4 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7 // indirect
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.3
Expand All @@ -16,5 +28,8 @@ require (
golang.org/x/sys v0.0.0-20210314195730-07df6a141424 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4 // indirect
)
Loading

0 comments on commit a2bc52e

Please sign in to comment.