Skip to content

Commit 9cdb923

Browse files
authored
chore: run go fix ./... (#923)
* chore: run go fix ./... --------- Signed-off-by: Chris Randles <randles.chris@gmail.com>
1 parent 4df0a3e commit 9cdb923

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ style:
117117
LINT_FLAGS ?=
118118
.PHONY: lint
119119
lint:
120+
@go fix -diff ./...
120121
@go tool golangci-lint run $(LINT_FLAGS) -c .golangci.yml
121122

122123
.PHONY: lint-fix
123124
lint-fix:
125+
@go fix ./...
124126
@LINT_FLAGS="--fix" $(MAKE) lint
125127
@go tool golangci-lint fmt -c .golangci.yml
126128

pkg/backends/healthcheck/target_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ func TestProbe(t *testing.T) {
264264
}, ts.Client())
265265
require.NoError(t, err)
266266
// start probe loop
267-
ctx, cancel := context.WithCancel(context.Background())
268-
defer cancel()
267+
ctx := t.Context()
269268
target.Start(ctx)
270269
time.Sleep((intervalMS + windowMS) * time.Millisecond)
271270
// verify results

pkg/locks/locks_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ func TestLocks(t *testing.T) {
3131

3232
nl, _ := lk.Acquire("test")
3333
wg := sync.WaitGroup{}
34-
wg.Add(1)
35-
go func() {
34+
wg.Go(func() {
3635
nl2, _ := lk.Acquire("test")
3736
testVal += 10
3837
nl2.Release()
39-
wg.Done()
40-
}()
38+
})
4139
testVal++
4240
if testVal != 1 {
4341
t.Errorf("expected 1 got %d", testVal)
@@ -123,7 +121,7 @@ func TestLocksUpgradePileup(t *testing.T) {
123121
errLock.Unlock()
124122
}
125123

126-
for i := 0; i < size; i++ {
124+
for range size {
127125
go func() {
128126
nl, err := lk.RAcquire(testKey)
129127
if err != nil {
@@ -159,7 +157,7 @@ func TestLocksConcurrent(t *testing.T) {
159157
errLock.Unlock()
160158
}
161159

162-
for i := 0; i < size; i++ {
160+
for i := range size {
163161
go func(j int) {
164162
time.Sleep(time.Duration(rand.Int63()%5000000) * time.Nanosecond)
165163
if j%3 == 0 {
@@ -221,13 +219,11 @@ func TestLockReadAndWrite(t *testing.T) {
221219
t.Error("expected error for invalid key name")
222220
}
223221

224-
wg.Add(1)
225-
go func() {
222+
wg.Go(func() {
226223
nl1, _ := lk.RAcquire("test")
227224
j = i
228225
nl1.RRelease()
229-
wg.Done()
230-
}()
226+
})
231227

232228
i = 10
233229
nl.Release()

pkg/proxy/engines/progressive_collapse_forwarder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestPCFReadWriteGetBody(t *testing.T) {
129129

130130
func TestPCFWaits(t *testing.T) {
131131
var testStringLong string
132-
for i := 0; i < 32000; i++ {
132+
for range 32000 {
133133
testStringLong += "DEADBEEF"
134134
}
135135
w := bytes.NewBuffer(make([]byte, 0, len(testStringLong)))

pkg/proxy/ranges/byterange/multipart_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const (
3636
testPart2Body = `{ "body": "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ" }`
3737
)
3838

39-
var content = []byte(fmt.Sprintf(`--%s
39+
var content = fmt.Appendf(nil, `--%s
4040
Content-Type: %s
4141
Content-Range: bytes %s/%s
4242
@@ -48,7 +48,7 @@ Content-Range: bytes %s/%s
4848
%s
4949
--%s--`, testSeparator, testContentType1, testRange1, testContentLength,
5050
testPart1Body, testSeparator, testContentType1, testRange2, testContentLength,
51-
testPart2Body, testSeparator))
51+
testPart2Body, testSeparator)
5252

5353
func TestParseMultipartRangeResponseBody(t *testing.T) {
5454
reader := io.NopCloser(bytes.NewBuffer(content))

pkg/proxy/ranges/byterange/range_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func TestRangesFilter(t *testing.T) {
224224
if len(bs0) != len(bs1) {
225225
return fmt.Errorf("slice lengths %d and %d not eq", len(bs0), len(bs1))
226226
}
227-
for i := 0; i < len(bs0); i++ {
227+
for i := range bs0 {
228228
if bs0[i] != bs1[i] {
229229
return fmt.Errorf("slices not eq at %d, got %b and %b", i, bs0[i], bs1[i])
230230
}

pkg/timeseries/dataset/point_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func testPoints3() Points {
7575

7676
func genTestPoints(baseEpoch, n int) Points {
7777
points := make(Points, n)
78-
for i := 0; i < n; i++ {
78+
for i := range n {
7979
points[i] = Point{
8080
Epoch: epoch.Epoch((i * 10 * timeseries.Second) + baseEpoch),
8181
Size: 27,

pkg/timeseries/extent_list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ func genBenchmarkExtentList(len int, step time.Duration) (el ExtentList, start,
11461146
end = time.Now()
11471147
start = end.Add(time.Duration(-1*len) * step)
11481148
el = make(ExtentList, len)
1149-
for i := 0; i < len; i++ {
1149+
for i := range len {
11501150
el[i] = Extent{
11511151
Start: start.Add(time.Duration(i) * step),
11521152
End: start.Add(time.Duration(i+1) * step),

0 commit comments

Comments
 (0)