Skip to content

Commit 116390a

Browse files
authored
Organize imports in groups (#139)
Signed-off-by: wuxu <[email protected]>
1 parent 8a08ee3 commit 116390a

Some content is hidden

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

52 files changed

+120
-78
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ env:
1212

1313
script:
1414
- diff -u <(echo -n) <(gofmt -d -s .)
15+
- diff -u <(echo -n) <(goimports -d .)
1516
- go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
1617

1718
after_success:
18-
- bash <(curl -s https://codecov.io/bash)
19+
- bash <(curl -s https://codecov.io/bash)

adapter/echo/middleware_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package echo
22

33
import (
4-
"github.com/labstack/echo/v4"
54
"io"
65
"net/http"
76
"net/http/httptest"
87
"testing"
98

109
sentinel "github.com/alibaba/sentinel-golang/api"
1110
"github.com/alibaba/sentinel-golang/core/flow"
11+
"github.com/labstack/echo/v4"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

adapter/grpc/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package grpc
33
import (
44
"context"
55
"errors"
6-
"github.com/alibaba/sentinel-golang/core/stat"
76
"testing"
87

98
sentinel "github.com/alibaba/sentinel-golang/api"
109
"github.com/alibaba/sentinel-golang/core/base"
1110
"github.com/alibaba/sentinel-golang/core/flow"
11+
"github.com/alibaba/sentinel-golang/core/stat"
1212
"github.com/stretchr/testify/assert"
1313
"google.golang.org/grpc"
1414
)

api/api_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package api
22

33
import (
4+
"testing"
5+
46
"github.com/alibaba/sentinel-golang/core/base"
57
"github.com/stretchr/testify/assert"
68
"github.com/stretchr/testify/mock"
7-
"testing"
89
)
910

1011
type prepareSlotMock struct {

api/init.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package api
22

33
import (
44
"fmt"
5+
56
"github.com/alibaba/sentinel-golang/core/config"
67
"github.com/alibaba/sentinel-golang/core/log/metric"
78
"github.com/alibaba/sentinel-golang/core/system"

core/base/context_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package base
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
5+
6+
"github.com/stretchr/testify/assert"
67
)
78

89
func TestEntryContext_IsBlocked(t *testing.T) {

core/base/metric_item_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package base
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"testing"
5+
6+
"github.com/stretchr/testify/assert"
67
)
78

89
func TestMetricItemFromFatStringLegal(t *testing.T) {

core/base/slot_chain.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package base
22

33
import (
4+
"sync"
5+
46
"github.com/alibaba/sentinel-golang/logging"
57
"github.com/alibaba/sentinel-golang/util"
6-
"sync"
78
)
89

910
var logger = logging.GetDefaultLogger()

core/base/slot_chain_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package base
22

33
import (
44
"fmt"
5-
"github.com/stretchr/testify/assert"
6-
"github.com/stretchr/testify/mock"
75
"reflect"
86
"strconv"
97
"testing"
108
"time"
9+
10+
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/mock"
1112
)
1213

1314
type StatPrepareSlotMock1 struct {

core/circuit_breaker/circuit_breaker.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package circuit_breaker
22

33
import (
4+
"sync/atomic"
5+
"time"
6+
47
"github.com/alibaba/sentinel-golang/core/base"
58
"github.com/alibaba/sentinel-golang/core/stat"
69
"github.com/alibaba/sentinel-golang/util"
7-
"sync/atomic"
8-
"time"
910
)
1011

1112
type CircuitBreaker interface {

core/circuit_breaker/rule.go

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package circuit_breaker
33
import (
44
"encoding/json"
55
"fmt"
6+
67
"github.com/alibaba/sentinel-golang/core/base"
78
"github.com/alibaba/sentinel-golang/util"
89
"github.com/pkg/errors"

core/circuit_breaker/rule_manager.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package circuit_breaker
22

33
import (
44
"fmt"
5-
"github.com/alibaba/sentinel-golang/logging"
65
"strings"
76
"sync"
7+
8+
"github.com/alibaba/sentinel-golang/logging"
89
)
910

1011
var (

core/circuit_breaker/rule_manager_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package circuit_breaker
22

33
import (
4-
"github.com/stretchr/testify/assert"
54
"reflect"
65
"testing"
6+
7+
"github.com/stretchr/testify/assert"
78
)
89

910
func Test_isApplicableRule(t *testing.T) {

core/circuit_breaker/slot.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package circuit_breaker
22

33
import (
4-
"github.com/alibaba/sentinel-golang/core/base"
54
"time"
5+
6+
"github.com/alibaba/sentinel-golang/core/base"
67
)
78

89
type CircuitBreakerSlot struct {

core/config/config.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package config
22

33
import (
44
"fmt"
5-
"github.com/alibaba/sentinel-golang/logging"
6-
"github.com/alibaba/sentinel-golang/util"
7-
"github.com/pkg/errors"
8-
"gopkg.in/yaml.v2"
95
"io/ioutil"
106
"log"
117
"os"
128
"strconv"
139
"sync"
10+
11+
"github.com/alibaba/sentinel-golang/logging"
12+
"github.com/alibaba/sentinel-golang/util"
13+
"github.com/pkg/errors"
14+
"gopkg.in/yaml.v2"
1415
)
1516

1617
var (

core/flow/rule_manager_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package flow
22

33
import (
4-
"github.com/stretchr/testify/assert"
5-
64
"testing"
5+
6+
"github.com/stretchr/testify/assert"
77
)
88

99
func TestSetAndRemoveTrafficShapingGenerator(t *testing.T) {

core/flow/slot.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package flow
22

33
import (
4+
"time"
5+
46
"github.com/alibaba/sentinel-golang/core/base"
57
"github.com/alibaba/sentinel-golang/core/stat"
6-
"time"
78
)
89

910
// FlowSlot

core/flow/tc_throttling.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package flow
22

33
import (
4-
"github.com/alibaba/sentinel-golang/core/base"
5-
"github.com/alibaba/sentinel-golang/util"
64
"math"
75
"sync/atomic"
86
"time"
7+
8+
"github.com/alibaba/sentinel-golang/core/base"
9+
"github.com/alibaba/sentinel-golang/util"
910
)
1011

1112
const nanoUnitOffset = time.Second / time.Nanosecond

core/flow/tc_throttling_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package flow
22

33
import (
4-
"github.com/alibaba/sentinel-golang/core/base"
5-
"github.com/stretchr/testify/assert"
64
"sync"
75
"sync/atomic"
86
"testing"
97
"time"
8+
9+
"github.com/alibaba/sentinel-golang/core/base"
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestThrottlingChecker_DoCheckNoQueueingSingleThread(t *testing.T) {

core/log/metric/aggregator.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package metric
22

33
import (
4+
"sort"
5+
"sync"
6+
"time"
7+
48
"github.com/alibaba/sentinel-golang/core/base"
59
"github.com/alibaba/sentinel-golang/core/config"
610
"github.com/alibaba/sentinel-golang/core/stat"
711
"github.com/alibaba/sentinel-golang/logging"
812
"github.com/alibaba/sentinel-golang/util"
9-
"sort"
10-
"sync"
11-
"time"
1213
)
1314

1415
type metricTimeMap = map[uint64][]*base.MetricItem

core/log/metric/aggregator_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package metric
22

33
import (
4+
"testing"
5+
46
"github.com/alibaba/sentinel-golang/core/base"
57
"github.com/alibaba/sentinel-golang/core/stat"
68
"github.com/stretchr/testify/assert"
79
"github.com/stretchr/testify/mock"
8-
"testing"
910
)
1011

1112
const (

core/log/metric/common.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package metric
22

33
import (
4-
"github.com/alibaba/sentinel-golang/core/base"
54
"io/ioutil"
65
"os"
76
"path/filepath"
87
"regexp"
98
"sort"
109
"strconv"
1110
"strings"
11+
12+
"github.com/alibaba/sentinel-golang/core/base"
1213
)
1314

1415
const (

core/log/metric/reader.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package metric
22

33
import (
44
"bufio"
5-
"github.com/alibaba/sentinel-golang/core/base"
6-
"github.com/pkg/errors"
75
"io"
86
"os"
7+
8+
"github.com/alibaba/sentinel-golang/core/base"
9+
"github.com/pkg/errors"
910
)
1011

1112
const maxItemAmount = 100000

core/log/metric/searcher.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package metric
22

33
import (
44
"encoding/binary"
5-
"github.com/alibaba/sentinel-golang/core/base"
6-
"github.com/alibaba/sentinel-golang/util"
7-
"github.com/pkg/errors"
85
"io"
96
"os"
107
"sync"
8+
9+
"github.com/alibaba/sentinel-golang/core/base"
10+
"github.com/alibaba/sentinel-golang/util"
11+
"github.com/pkg/errors"
1112
)
1213

1314
const offsetNotFound = -1

core/log/metric/writer.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import (
44
"bufio"
55
"encoding/binary"
66
"fmt"
7-
"github.com/alibaba/sentinel-golang/core/base"
8-
"github.com/alibaba/sentinel-golang/core/config"
9-
"github.com/alibaba/sentinel-golang/util"
10-
"github.com/pkg/errors"
117
"os"
128
"strconv"
139
"strings"
1410
"sync"
1511
"time"
12+
13+
"github.com/alibaba/sentinel-golang/core/base"
14+
"github.com/alibaba/sentinel-golang/core/config"
15+
"github.com/alibaba/sentinel-golang/util"
16+
"github.com/pkg/errors"
1617
)
1718

1819
type DefaultMetricLogWriter struct {

core/stat/base/atomic_window_wrap_array_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package base
22

33
import (
4-
"github.com/alibaba/sentinel-golang/util"
54
"math/rand"
65
"reflect"
76
"sync"
87
"sync/atomic"
98
"testing"
109
"time"
10+
11+
"github.com/alibaba/sentinel-golang/util"
1112
)
1213

1314
func Test_newAtomicBucketWrapArray_normal(t *testing.T) {

core/stat/base/bucket_leap_array.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package base
22

33
import (
44
"fmt"
5+
"sync/atomic"
6+
57
"github.com/alibaba/sentinel-golang/core/base"
68
"github.com/alibaba/sentinel-golang/logging"
79
"github.com/alibaba/sentinel-golang/util"
810
"github.com/pkg/errors"
9-
"sync/atomic"
1011
)
1112

1213
var logger = logging.GetDefaultLogger()

core/stat/base/leap_array.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package base
22

33
import (
44
"fmt"
5-
"github.com/alibaba/sentinel-golang/core/base"
6-
"github.com/alibaba/sentinel-golang/util"
7-
"github.com/pkg/errors"
85
"runtime"
96
"sync/atomic"
107
"unsafe"
8+
9+
"github.com/alibaba/sentinel-golang/core/base"
10+
"github.com/alibaba/sentinel-golang/util"
11+
"github.com/pkg/errors"
1112
)
1213

1314
const (

0 commit comments

Comments
 (0)