Skip to content

Commit 2bfe114

Browse files
authored
chore(lint): Format with goimports, enforce go mod tidy (salesforce#247)
* chore(lint): Format with goimports * chore(lint): Install goimports to avoid go.sum requirement * chore(lint): Enforce goimports formatting and go mod tidy * chore(ci): Remove Travis CI file, GHA used now
1 parent fdfea71 commit 2bfe114

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+189
-142
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ jobs:
2424
go-version-file: go.mod
2525

2626
- name: Format with goimports
27-
# TODO: Enforce when possible.
2827
run: |
29-
if [ "$(go run golang.org/x/tools/cmd/goimports -l --format-only . | wc -l)" -gt 0 ];
28+
go install golang.org/x/tools/cmd/goimports@latest
29+
if [ "$(goimports -l --format-only . | wc -l)" -gt 0 ];
3030
then
31-
go run golang.org/x/tools/cmd/goimports -l --format-only .
32-
exit 0
31+
goimports -l --format-only .
32+
exit 1
3333
fi
3434
3535
- name: Run go vet
@@ -42,10 +42,9 @@ jobs:
4242
go test -v -race ./...
4343
4444
- name: Run go mod tidy
45-
# TODO: Enforce when possible.
4645
run: |
4746
go mod tidy
48-
git diff --exit-code -- go.mod go.sum || true
47+
git diff --exit-code -- go.mod go.sum
4948
5049
- name: Run go build
5150
run: go build ./pkg/sloop/main.go

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

pkg/sloop/common/db_utilities_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package common
22

33
import (
4+
"testing"
5+
46
"github.com/dgraph-io/badger/v2"
57
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
68
"github.com/stretchr/testify/assert"
7-
"testing"
89
)
910

1011
var commonPrefix = "/commonprefix/001546405200/"

pkg/sloop/common/partition_utilities.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package common
22

33
import (
4+
"sort"
5+
46
"github.com/dgraph-io/badger/v2"
57
"github.com/golang/glog"
68
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
7-
"sort"
89
)
910

1011
type SloopKey struct {

pkg/sloop/common/utilities_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package common
22

33
import (
44
"fmt"
5-
"github.com/stretchr/testify/assert"
65
"path"
76
"testing"
7+
8+
"github.com/stretchr/testify/assert"
89
)
910

1011
var files = []string{"webfiles/index.html", "webfiles/debug.html", "webfiles/filter.js", "webfiles/sloop.cs"}

pkg/sloop/ingress/fileplayback.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
package ingress
99

1010
import (
11+
"io/ioutil"
12+
1113
"github.com/ghodss/yaml"
1214
"github.com/golang/glog"
1315
"github.com/salesforce/sloop/pkg/sloop/store/typed"
14-
"io/ioutil"
1516
)
1617

1718
func PlayFile(outChan chan typed.KubeWatchResult, filename string) error {

pkg/sloop/ingress/filerecorder.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
package ingress
99

1010
import (
11+
"io/ioutil"
12+
"sync"
13+
1114
"github.com/ghodss/yaml"
1215
"github.com/golang/glog"
1316
"github.com/salesforce/sloop/pkg/sloop/store/typed"
14-
"io/ioutil"
15-
"sync"
1617
)
1718

1819
type FileRecorder struct {

pkg/sloop/ingress/kubeclient_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package ingress
22

33
import (
4+
"testing"
5+
46
"github.com/stretchr/testify/assert"
57
"k8s.io/client-go/rest"
68
"k8s.io/client-go/tools/clientcmd"
79
"k8s.io/client-go/tools/clientcmd/api"
8-
"testing"
910
)
1011

1112
func TestGetKubernetesContext(t *testing.T) {

pkg/sloop/kubeextractor/events.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ package kubeextractor
1010
import (
1111
"encoding/json"
1212
"fmt"
13-
"github.com/golang/glog"
1413
"strings"
1514
"time"
15+
16+
"github.com/golang/glog"
1617
)
1718

1819
// Example Event

pkg/sloop/kubeextractor/events_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
package kubeextractor
99

1010
import (
11-
"github.com/stretchr/testify/assert"
1211
"testing"
1312
"time"
13+
14+
"github.com/stretchr/testify/assert"
1415
)
1516

1617
func Test_ExtractInvolvedObject_OutputCorrect(t *testing.T) {

0 commit comments

Comments
 (0)