Skip to content

Commit c7978a5

Browse files
authored
repo: setup golangci lint (#52)
* repo: setup golangci lint * repo: fixup linter warnings
1 parent 4a5569c commit c7978a5

6 files changed

Lines changed: 26 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
name: run-ci
1+
name: Run CI Tests
22
on: [push]
33
jobs:
4+
run-lint:
5+
runs-on: ubuntu-22.04
6+
steps:
7+
- uses: actions/checkout@v3
8+
- uses: hashicorp/setup-golang@v1
9+
with:
10+
version-file: go.mod
11+
- uses: golangci/golangci-lint-action@v3
12+
with:
13+
version: v1.52.2
14+
skip-cache: true
415
run-tests:
516
strategy:
617
fail-fast: false

.golangci.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
run:
2+
timeout: 5m
3+
linters:
4+
enable:
5+
- gofmt
6+
- errcheck
7+
- errname
8+
- errorlint
9+
- durationcheck
10+
- whitespace
11+

internal/netapi/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package netapi
22

33
import (
4-
"fmt"
54
"net/http"
65
"time"
76

@@ -20,5 +19,5 @@ var (
2019
httpClient = &http.Client{Timeout: 10 * time.Second}
2120

2221
// the user-agent to use for all http requests
23-
userAgent = fmt.Sprintf("ssh-key-sync bot/v2 (https://github.com/shoenig/ssh-key-sync)")
22+
userAgent = "ssh-key-sync bot/v2 (https://github.com/shoenig/ssh-key-sync)"
2423
)

internal/ssh/keys_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func Test_Key_String_empty(t *testing.T) {
4141
}
4242

4343
func Test_sortByMetadata(t *testing.T) {
44-
4544
keys := []Key{
4645
key(true, "ned", "h5", "xcvwe"),
4746
key(false, "xavior", "h4", "lkdsf"),

internal/ssh/reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func compareToFile(t *testing.T, filename string, expected []Key) {
1010
reader := NewKeysReader()
1111
keys, err := reader.ReadKeys(filename)
1212
must.NoError(t, err)
13-
must.SliceContainsAll(t, expected, keys.List())
13+
must.SliceContainsAll(t, expected, keys.Slice())
1414
}
1515

1616
func Test_read_1(t *testing.T) {

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ func main() {
1212
fmt.Println("[fatal]", err)
1313
os.Exit(1)
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)