From 16b6a3cc312fa27ee8979b41cb6e269a0eaaa7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=AC=A7?= Date: Tue, 22 Aug 2017 22:15:01 +0800 Subject: [PATCH] Adjust package order (#487) * format package order * format package order * format package order * format package order and format code by fmt --- elasticsearch.go | 6 ++++-- examples/middleware/token_modifier.go | 3 ++- http_client_test.go | 3 ++- http_modifier_test.go | 3 ++- http_prettifier.go | 3 ++- input_http_test.go | 3 ++- input_kafka.go | 3 ++- input_kafka_test.go | 3 ++- input_raw.go | 5 +++-- input_raw_test.go | 3 ++- kafka.go | 4 +++- middleware_test.go | 3 ++- output_kafka.go | 8 +++++--- output_kafka_test.go | 3 ++- proto/proto.go | 9 +++++---- raw_socket_listener/listener.go | 10 ++++++---- raw_socket_listener/tcp_message.go | 3 ++- 17 files changed, 48 insertions(+), 27 deletions(-) diff --git a/elasticsearch.go b/elasticsearch.go index c111238..b83dabf 100644 --- a/elasticsearch.go +++ b/elasticsearch.go @@ -3,12 +3,14 @@ package main import ( "net/url" "encoding/json" - "github.com/buger/goreplay/proto" - "github.com/mattbaird/elastigo/lib" "log" "strings" //"regexp" "time" + + "github.com/buger/goreplay/proto" + + "github.com/mattbaird/elastigo/lib" ) type ESUriErorr struct{} diff --git a/examples/middleware/token_modifier.go b/examples/middleware/token_modifier.go index b715d76..a0013cd 100644 --- a/examples/middleware/token_modifier.go +++ b/examples/middleware/token_modifier.go @@ -24,8 +24,9 @@ import ( "bytes" "encoding/hex" "fmt" - "github.com/buger/goreplay/proto" "os" + + "github.com/buger/goreplay/proto" ) // requestID -> originalToken diff --git a/http_client_test.go b/http_client_test.go index 6d743ed..04283ab 100644 --- a/http_client_test.go +++ b/http_client_test.go @@ -3,7 +3,6 @@ package main import ( "bytes" "crypto/rand" - "github.com/buger/goreplay/proto" "io/ioutil" _ "log" "net" @@ -15,6 +14,8 @@ import ( "sync" "testing" "time" + + "github.com/buger/goreplay/proto" ) func TestHTTPClientURLPort(t *testing.T) { diff --git a/http_modifier_test.go b/http_modifier_test.go index 6e4ee48..2d25fe9 100644 --- a/http_modifier_test.go +++ b/http_modifier_test.go @@ -2,8 +2,9 @@ package main import ( "bytes" - "github.com/buger/goreplay/proto" "testing" + + "github.com/buger/goreplay/proto" ) func TestHTTPModifierWithoutConfig(t *testing.T) { diff --git a/http_prettifier.go b/http_prettifier.go index 0550328..6f585c7 100644 --- a/http_prettifier.go +++ b/http_prettifier.go @@ -3,10 +3,11 @@ package main import ( "bytes" "compress/gzip" - "github.com/buger/goreplay/proto" "io/ioutil" "net/http/httputil" "strconv" + + "github.com/buger/goreplay/proto" ) func prettifyHTTP(p []byte) []byte { diff --git a/input_http_test.go b/input_http_test.go index 5f6dd4c..0d09fd1 100644 --- a/input_http_test.go +++ b/input_http_test.go @@ -1,7 +1,6 @@ package main import ( - "github.com/buger/goreplay/proto" "io" "log" "net/http" @@ -9,6 +8,8 @@ import ( "strings" "sync" "testing" + + "github.com/buger/goreplay/proto" ) func TestHTTPInput(t *testing.T) { diff --git a/input_kafka.go b/input_kafka.go index 25e6d72..37a8b16 100644 --- a/input_kafka.go +++ b/input_kafka.go @@ -2,9 +2,10 @@ package main import ( "encoding/json" + "log" + "github.com/Shopify/sarama" "github.com/Shopify/sarama/mocks" - "log" ) // KafkaInput is used for recieving Kafka messages and diff --git a/input_kafka_test.go b/input_kafka_test.go index f987ccd..9c0c7f1 100644 --- a/input_kafka_test.go +++ b/input_kafka_test.go @@ -1,9 +1,10 @@ package main import ( + "testing" + "github.com/Shopify/sarama" "github.com/Shopify/sarama/mocks" - "testing" ) func TestInputKafkaRAW(t *testing.T) { diff --git a/input_raw.go b/input_raw.go index eca2d16..eec5002 100644 --- a/input_raw.go +++ b/input_raw.go @@ -1,11 +1,12 @@ package main import ( - "github.com/buger/goreplay/proto" - raw "github.com/buger/goreplay/raw_socket_listener" "log" "net" "time" + + "github.com/buger/goreplay/proto" + raw "github.com/buger/goreplay/raw_socket_listener" ) // RAWInput used for intercepting traffic for given address diff --git a/input_raw_test.go b/input_raw_test.go index c11a27c..099b393 100644 --- a/input_raw_test.go +++ b/input_raw_test.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "github.com/buger/goreplay/proto" "io" "io/ioutil" "log" @@ -19,6 +18,8 @@ import ( "sync/atomic" "testing" "time" + + "github.com/buger/goreplay/proto" ) const testRawExpire = time.Millisecond * 200 diff --git a/kafka.go b/kafka.go index bc5c56a..2f55205 100644 --- a/kafka.go +++ b/kafka.go @@ -3,8 +3,10 @@ package main import ( "bytes" "fmt" - "github.com/Shopify/sarama" + "github.com/buger/goreplay/proto" + + "github.com/Shopify/sarama" ) // KafkaConfig should contains required information to diff --git a/middleware_test.go b/middleware_test.go index b135d86..c828b85 100644 --- a/middleware_test.go +++ b/middleware_test.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/rand" "encoding/hex" - "github.com/buger/goreplay/proto" "io" "net/http" "net/http/httptest" @@ -12,6 +11,8 @@ import ( "sync" "testing" "time" + + "github.com/buger/goreplay/proto" ) type fakeServiceCb func(string, int, []byte) diff --git a/output_kafka.go b/output_kafka.go index 7a6309a..07b35b6 100644 --- a/output_kafka.go +++ b/output_kafka.go @@ -2,13 +2,15 @@ package main import ( "encoding/json" - "github.com/Shopify/sarama" - "github.com/Shopify/sarama/mocks" - "github.com/buger/goreplay/proto" "io" "log" "strings" "time" + + "github.com/buger/goreplay/proto" + + "github.com/Shopify/sarama" + "github.com/Shopify/sarama/mocks" ) // KafkaOutput is used for sending payloads to kafka in JSON format. diff --git a/output_kafka_test.go b/output_kafka_test.go index cf9efe0..30a58e0 100644 --- a/output_kafka_test.go +++ b/output_kafka_test.go @@ -1,9 +1,10 @@ package main import ( + "testing" + "github.com/Shopify/sarama" "github.com/Shopify/sarama/mocks" - "testing" ) func TestOutputKafkaRAW(t *testing.T) { diff --git a/proto/proto.go b/proto/proto.go index 31b8507..d149d0f 100644 --- a/proto/proto.go +++ b/proto/proto.go @@ -18,6 +18,7 @@ package proto import ( "bytes" + "github.com/buger/goreplay/byteutils" ) @@ -348,18 +349,18 @@ func Path(payload []byte) []byte { if eol > 0 { if end == -1 || eol < end { - return payload[start : start + eol] + return payload[start : start+eol] } } else { // support for legacy clients eol = bytes.IndexByte(payload[start:], '\n') - if eol > 0 && (end == - 1 || eol < end) { - return payload[start : start + eol] + if eol > 0 && (end == -1 || eol < end) { + return payload[start : start+eol] } } if end < 0 { - return payload[start: len(payload)] + return payload[start:len(payload)] } return payload[start : start+end] diff --git a/raw_socket_listener/listener.go b/raw_socket_listener/listener.go index 6e5c2dd..1f823eb 100644 --- a/raw_socket_listener/listener.go +++ b/raw_socket_listener/listener.go @@ -16,10 +16,6 @@ import ( "bytes" "encoding/binary" "fmt" - "github.com/buger/goreplay/proto" - "github.com/google/gopacket" - "github.com/google/gopacket/layers" - "github.com/google/gopacket/pcap" "io" "log" "net" @@ -29,6 +25,12 @@ import ( "strings" "sync" "time" + + "github.com/buger/goreplay/proto" + + "github.com/google/gopacket" + "github.com/google/gopacket/layers" + "github.com/google/gopacket/pcap" ) var _ = fmt.Println diff --git a/raw_socket_listener/tcp_message.go b/raw_socket_listener/tcp_message.go index 59d280f..dbda8b5 100644 --- a/raw_socket_listener/tcp_message.go +++ b/raw_socket_listener/tcp_message.go @@ -5,11 +5,12 @@ import ( "crypto/sha1" "encoding/binary" "encoding/hex" - "github.com/buger/goreplay/proto" "log" "net" "strconv" "time" + + "github.com/buger/goreplay/proto" ) var _ = log.Println