Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standardize imports #1466

Merged
merged 10 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions api/health/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package health

import (
"github.com/prometheus/client_golang/prometheus"
)
import "github.com/prometheus/client_golang/prometheus"

type metrics struct {
// failingChecks keeps track of the number of check failing
Expand Down
4 changes: 1 addition & 3 deletions api/health/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package health

import (
"time"
)
import "time"

// notYetRunResult is the result that is returned when a HealthCheck hasn't been
// run yet.
Expand Down
4 changes: 1 addition & 3 deletions api/server/middleware_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package server

import (
"net/http"
)
import "net/http"

type middlewareHandler struct {
before, after func()
Expand Down
4 changes: 1 addition & 3 deletions api/server/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package server

import (
"net/http"
)
import "net/http"

type Wrapper interface {
// WrapHandler wraps an http.Handler.
Expand Down
4 changes: 1 addition & 3 deletions chains/atomic/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package atomic

import (
"github.com/ava-labs/avalanchego/database"
)
import "github.com/ava-labs/avalanchego/database"

// WriteAll writes all of the batches to the underlying database of baseBatch.
// Assumes all batches have the same underlying database.
Expand Down
4 changes: 1 addition & 3 deletions ids/test_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package ids

import (
"sync/atomic"
)
import "sync/atomic"

var offset = uint64(0)

Expand Down
4 changes: 1 addition & 3 deletions network/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package network

import (
"net"
)
import "net"

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

Expand Down
8 changes: 7 additions & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fi
# by default, "./scripts/lint.sh" runs all lint tests
# to run only "license_header" test
# TESTS='license_header' ./scripts/lint.sh
TESTS=${TESTS:-"golangci_lint license_header"}
TESTS=${TESTS:-"golangci_lint license_header single_import"}

function test_golangci_lint {
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
Expand Down Expand Up @@ -51,6 +51,12 @@ function test_license_header {
"${files[@]}"
}

function test_single_import {
if grep -R -zo -e 'import (\n\t".*"\n)' .; then
return 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also add a log to say why the linter failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does print it:

START: 'single_import' at Thu May  4 17:37:48 EDT 2023
./snow/consensus/snowball/binary_slush.go:import (
        "fmt"
)
./snow/consensus/snowball/binary_snowflake.go:import (
        "fmt"
)
./snow/consensus/snowball/binary_snowball.go:import (
        "fmt"
)
FAIL: 'single_import' failed at Thu May  4 17:37:50 EDT 2023

fi
}

function run {
local test="${1}"
shift 1
Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/metrics/height.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package metrics

import (
"github.com/prometheus/client_golang/prometheus"
)
import "github.com/prometheus/client_golang/prometheus"

var _ Height = (*height)(nil)

Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowball/binary_snowball_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowball

import (
"testing"
)
import "testing"

func TestBinarySnowball(t *testing.T) {
red := 0
Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowball/binary_snowflake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowball

import (
"testing"
)
import "testing"

func TestBinarySnowflake(t *testing.T) {
blue := 0
Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowball/nnary_snowball_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowball

import (
"testing"
)
import "testing"

func TestNnarySnowball(t *testing.T) {
betaVirtuous := 2
Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowball/nnary_snowflake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowball

import (
"testing"
)
import "testing"

func TestNnarySnowflake(t *testing.T) {
betaVirtuous := 2
Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowball/unary_snowball.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowball

import (
"fmt"
)
import "fmt"

var _ UnarySnowball = (*unarySnowball)(nil)

Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowball/unary_snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowball

import (
"fmt"
)
import "fmt"

var _ UnarySnowflake = (*unarySnowflake)(nil)

Expand Down
4 changes: 1 addition & 3 deletions snow/consensus/snowman/topological_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package snowman

import (
"testing"
)
import "testing"

func TestTopological(t *testing.T) {
runConsensusTests(t, TopologicalFactory{})
Expand Down
4 changes: 1 addition & 3 deletions snow/engine/common/bootstrap_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package common

import (
"github.com/ava-labs/avalanchego/ids"
)
import "github.com/ava-labs/avalanchego/ids"

// BootstrapTracker describes the standard interface for tracking the status of
// a subnet bootstrapping
Expand Down
4 changes: 1 addition & 3 deletions snow/engine/common/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package common

import (
"github.com/ava-labs/avalanchego/ids"
)
import "github.com/ava-labs/avalanchego/ids"

// Fx wraps an instance of a feature extension
type Fx struct {
Expand Down
4 changes: 1 addition & 3 deletions snow/engine/common/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package common

import (
"net/http"
)
import "net/http"

// LockOption allows the vm to specify their lock option based on their endpoint
type LockOption uint32
Expand Down
4 changes: 1 addition & 3 deletions snow/engine/common/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package common

import (
"fmt"
)
import "fmt"

// TODO: Consider renaming Message to, say, VMMessage

Expand Down
4 changes: 1 addition & 3 deletions snow/engine/common/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package common

import (
"time"
)
import "time"

// Timer describes the standard interface for specifying a timeout
type Timer interface {
Expand Down
4 changes: 1 addition & 3 deletions snow/networking/benchlist/benchable.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package benchlist

import (
"github.com/ava-labs/avalanchego/ids"
)
import "github.com/ava-labs/avalanchego/ids"

// Benchable is notified when a validator is benched or unbenched from a given chain
type Benchable interface {
Expand Down
4 changes: 1 addition & 3 deletions snow/networking/worker/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package worker

import (
"sync"
)
import "sync"

var _ Pool = (*pool)(nil)

Expand Down
4 changes: 1 addition & 3 deletions utils/atomic.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package utils

import (
"sync"
)
import "sync"

type Atomic[T any] struct {
lock sync.RWMutex
Expand Down
4 changes: 1 addition & 3 deletions utils/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package utils

import (
"crypto/rand"
)
import "crypto/rand"

// RandomBytes returns a slice of n random bytes
// Intended for use in testing
Expand Down
4 changes: 1 addition & 3 deletions utils/constants/network_ids_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package constants

import (
"testing"
)
import "testing"

func TestGetHRP(t *testing.T) {
tests := []struct {
Expand Down
4 changes: 1 addition & 3 deletions utils/crypto/secp256k1/test_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package secp256k1

import (
"github.com/ava-labs/avalanchego/utils/cb58"
)
import "github.com/ava-labs/avalanchego/utils/cb58"

func TestKeys() []*PrivateKey {
var (
Expand Down
4 changes: 1 addition & 3 deletions utils/filesystem/mock_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package filesystem

import (
"io/fs"
)
import "io/fs"

var _ fs.DirEntry = MockFile{}

Expand Down
4 changes: 1 addition & 3 deletions utils/formatting/address/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package address

import (
"github.com/ava-labs/avalanchego/ids"
)
import "github.com/ava-labs/avalanchego/ids"

func ParseToID(addrStr string) (ids.ShortID, error) {
_, _, addrBytes, err := Parse(addrStr)
Expand Down
4 changes: 1 addition & 3 deletions utils/formatting/int_format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package formatting

import (
"testing"
)
import "testing"

func TestIntFormat(t *testing.T) {
if format := IntFormat(0); format != "%01d" {
Expand Down
4 changes: 1 addition & 3 deletions utils/formatting/prefixed_stringer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package formatting

import (
"fmt"
)
import "fmt"

// PrefixedStringer extends a stringer that adds a prefix
type PrefixedStringer interface {
Expand Down
3 changes: 2 additions & 1 deletion utils/hashing/consistent/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"errors"
"sync"

"github.com/ava-labs/avalanchego/utils/hashing"
"github.com/google/btree"

"github.com/ava-labs/avalanchego/utils/hashing"
)

var (
Expand Down
4 changes: 1 addition & 3 deletions utils/json/float32.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package json

import (
"strconv"
)
import "strconv"

type Float32 float32

Expand Down
4 changes: 1 addition & 3 deletions utils/json/float64.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package json

import (
"strconv"
)
import "strconv"

type Float64 float64

Expand Down
4 changes: 1 addition & 3 deletions utils/json/uint16.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

package json

import (
"strconv"
)
import "strconv"

type Uint16 uint16

Expand Down
Loading