Skip to content

Commit a16d9fb

Browse files
authored
Standardize single import formats (ava-labs#1466)
1 parent 7b8bbd6 commit a16d9fb

Some content is hidden

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

68 files changed

+76
-200
lines changed

api/health/metrics.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package health
55

6-
import (
7-
"github.com/prometheus/client_golang/prometheus"
8-
)
6+
import "github.com/prometheus/client_golang/prometheus"
97

108
type metrics struct {
119
// failingChecks keeps track of the number of check failing

api/health/result.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package health
55

6-
import (
7-
"time"
8-
)
6+
import "time"
97

108
// notYetRunResult is the result that is returned when a HealthCheck hasn't been
119
// run yet.

api/server/middleware_handler.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package server
55

6-
import (
7-
"net/http"
8-
)
6+
import "net/http"
97

108
type middlewareHandler struct {
119
before, after func()

api/server/wrapper.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package server
55

6-
import (
7-
"net/http"
8-
)
6+
import "net/http"
97

108
type Wrapper interface {
119
// WrapHandler wraps an http.Handler.

chains/atomic/writer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package atomic
55

6-
import (
7-
"github.com/ava-labs/avalanchego/database"
8-
)
6+
import "github.com/ava-labs/avalanchego/database"
97

108
// WriteAll writes all of the batches to the underlying database of baseBatch.
119
// Assumes all batches have the same underlying database.

ids/test_generator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package ids
55

6-
import (
7-
"sync/atomic"
8-
)
6+
import "sync/atomic"
97

108
var offset = uint64(0)
119

network/conn_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package network
55

6-
import (
7-
"net"
8-
)
6+
import "net"
97

108
var _ net.Conn = (*testConn)(nil)
119

scripts/lint.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121
# by default, "./scripts/lint.sh" runs all lint tests
2222
# to run only "license_header" test
2323
# TESTS='license_header' ./scripts/lint.sh
24-
TESTS=${TESTS:-"golangci_lint license_header require_error_is_no_funcs_as_params"}
24+
TESTS=${TESTS:-"golangci_lint license_header require_error_is_no_funcs_as_params single_import"}
2525

2626
function test_golangci_lint {
2727
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
@@ -51,6 +51,13 @@ function test_license_header {
5151
"${files[@]}"
5252
}
5353

54+
function test_single_import {
55+
if grep -R -zo -P 'import \(\n\t".*"\n\)' .; then
56+
echo ""
57+
return 1
58+
fi
59+
}
60+
5461
function test_require_error_is_no_funcs_as_params {
5562
if grep -R -zo -P 'require.ErrorIs\(.+?\)[^\n]*\)\n' .; then
5663
echo ""

snow/consensus/metrics/height.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package metrics
55

6-
import (
7-
"github.com/prometheus/client_golang/prometheus"
8-
)
6+
import "github.com/prometheus/client_golang/prometheus"
97

108
var _ Height = (*height)(nil)
119

snow/consensus/snowball/binary_slush.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
package snowball
55

6-
import (
7-
"fmt"
8-
)
6+
import "fmt"
97

108
var _ BinarySlush = (*binarySlush)(nil)
119

0 commit comments

Comments
 (0)