Skip to content

Commit a382f92

Browse files
authored
Merge pull request #111 from 99designs/add-golangci-lint
Add golangci-lint and fix linting issues
2 parents 932029a + 859d578 commit a382f92

22 files changed

+165
-140
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.go text eol=lf

.github/workflows/lint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: golangci-lint
2+
on: push
3+
jobs:
4+
golangci:
5+
strategy:
6+
matrix:
7+
go-version: [1.15.x]
8+
os: [macos-latest, windows-latest, ubuntu-latest]
9+
name: lint
10+
runs-on: ${{ matrix.os }}
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-go@v2
14+
with:
15+
go-version: 1.17
16+
- name: golangci-lint
17+
uses: golangci/golangci-lint-action@v2
18+
with:
19+
version: v1.44.2
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
11
name: Continuous Integration
22
on: push
3-
43
jobs:
5-
64
linux:
75
runs-on: ubuntu-latest
86
steps:
97
- uses: actions/setup-go@v2
108
with:
119
go-version: 1.17
1210
- run: sudo apt-get install pass gnome-keyring dbus-x11
13-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v2
1412
- run: go test -race ./...
15-
- run: go vet ./...
16-
1713
mac:
18-
runs-on: macOS-latest
14+
runs-on: macos-latest
1915
steps:
2016
- uses: actions/setup-go@v2
2117
with:
2218
go-version: 1.17
2319
- run: brew install pass gnupg
24-
- uses: actions/checkout@v1
20+
- uses: actions/checkout@v2
2521
- run: go test -race ./...
26-
- run: go vet ./...
27-
28-
lint:
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/setup-go@v2
32-
with:
33-
go-version: 1.17
34-
- uses: actions/checkout@v1
35-
- run: diff -u <(echo -n) <(gofmt -s -d .)

.golangci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
linters:
2+
enable:
3+
- bodyclose
4+
- contextcheck
5+
- deadcode
6+
- depguard
7+
- durationcheck
8+
- dupl
9+
- errcheck
10+
- errchkjson
11+
- errname
12+
- exhaustive
13+
- exportloopref
14+
- gocritic
15+
- gofmt
16+
- goimports
17+
- gosimple
18+
- govet
19+
- ineffassign
20+
- makezero
21+
- misspell
22+
- nakedret
23+
- nilerr
24+
- nilnil
25+
- noctx
26+
- prealloc
27+
- revive
28+
- rowserrcheck
29+
- staticcheck
30+
- structcheck
31+
- thelper
32+
- tparallel
33+
- typecheck
34+
- unconvert
35+
- unparam
36+
- unused
37+
- varcheck
38+
- wastedassign
39+
- whitespace

array.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package keyring
22

33
// ArrayKeyring is a mock/non-secure backend that meets the Keyring interface.
44
// It is intended to be used to aid unit testing of code that relies on the package.
5-
// NOTE: Do not use in production code
5+
// NOTE: Do not use in production code.
66
type ArrayKeyring struct {
77
items map[string]Item
88
}
99

1010
// NewArrayKeyring returns an ArrayKeyring, optionally constructed with an initial slice
11-
// of items
11+
// of items.
1212
func NewArrayKeyring(initial []Item) *ArrayKeyring {
1313
kr := &ArrayKeyring{}
1414
for _, i := range initial {
@@ -17,15 +17,15 @@ func NewArrayKeyring(initial []Item) *ArrayKeyring {
1717
return kr
1818
}
1919

20-
// Get returns an Item matching Key
20+
// Get returns an Item matching Key.
2121
func (k *ArrayKeyring) Get(key string) (Item, error) {
2222
if i, ok := k.items[key]; ok {
2323
return i, nil
2424
}
2525
return Item{}, ErrKeyNotFound
2626
}
2727

28-
// Set will store an item on the mock Keyring
28+
// Set will store an item on the mock Keyring.
2929
func (k *ArrayKeyring) Set(i Item) error {
3030
if k.items == nil {
3131
k.items = map[string]Item{}
@@ -34,13 +34,13 @@ func (k *ArrayKeyring) Set(i Item) error {
3434
return nil
3535
}
3636

37-
// Remove will delete an Item from the Keyring
37+
// Remove will delete an Item from the Keyring.
3838
func (k *ArrayKeyring) Remove(key string) error {
3939
delete(k.items, key)
4040
return nil
4141
}
4242

43-
// Keys provides a slice of all Item keys on the Keyring
43+
// Keys provides a slice of all Item keys on the Keyring.
4444
func (k *ArrayKeyring) Keys() ([]string, error) {
4545
var keys = []string{}
4646
for key := range k.items {

cmd/keyring/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,6 @@ func hasBackend(key string) bool {
104104
return true
105105
}
106106
}
107+
107108
return false
108109
}

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package keyring
22

3-
// Config contains configuration for keyring
3+
// Config contains configuration for keyring.
44
type Config struct {
55
// AllowedBackends is a whitelist of backend providers that can be used. Nil means all available.
66
AllowedBackends []BackendType

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "3.9"
2+
services:
3+
keyring:
4+
image: golang:1.17
5+
volumes:
6+
- .:/usr/local/src/keyring
7+
working_dir: /usr/local/src/keyring

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ require (
1010
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c
1111
github.com/mtibben/percent v0.2.1
1212
github.com/stretchr/testify v1.7.0
13-
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838
1413
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a
14+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
1515
)
1616

1717
require (
1818
github.com/davecgh/go-spew v1.1.1 // indirect
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
2020
github.com/stretchr/objx v0.3.0 // indirect
21-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
2221
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
2322
)

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,12 @@ github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
2626
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
2727
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
2828
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
29-
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE=
30-
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
31-
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
32-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
33-
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3429
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3530
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3631
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a h1:ppl5mZgokTT8uPkmYOyEUmPTr3ypaKkg5eFOGrAmxxE=
3732
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
38-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
3933
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
4034
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
41-
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
42-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
4335
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4436
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
4537
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)