From f88518d99446431ec6d8ec04cc21f201538a0060 Mon Sep 17 00:00:00 2001 From: tegk Date: Fri, 1 Nov 2019 15:07:53 +0000 Subject: [PATCH] used gofmt with -s flag on whole project --- api/handler/api/util_test.go | 2 +- api/handler/http/http_test.go | 2 +- broker/common_test.go | 2 +- broker/http_broker_test.go | 2 +- client/common_test.go | 2 +- client/grpc/grpc_test.go | 2 +- client/rpc_client_test.go | 2 +- client/selector/common_test.go | 2 +- client/selector/dns/dns.go | 2 +- client/selector/filter_test.go | 40 +++++++++++++++---------------- client/selector/strategy_test.go | 12 +++++----- common_test.go | 2 +- config/reader/json/values_test.go | 2 +- errors/errors_test.go | 2 +- monitor/default.go | 8 +++---- proxy/http/http.go | 2 +- proxy/mucp/mucp.go | 2 +- registry/encoding_test.go | 4 ++-- registry/mdns_test.go | 12 +++++----- registry/memory/memory_test.go | 4 ++-- registry/watcher_test.go | 12 +++++----- router/service/service.go | 2 +- server/grpc/grpc.go | 2 +- server/rpc_server.go | 2 +- tunnel/default.go | 2 +- web/service.go | 2 +- 26 files changed, 65 insertions(+), 65 deletions(-) diff --git a/api/handler/api/util_test.go b/api/handler/api/util_test.go index 0a82a03d..9350bcde 100644 --- a/api/handler/api/util_test.go +++ b/api/handler/api/util_test.go @@ -8,7 +8,7 @@ import ( func TestRequestToProto(t *testing.T) { testData := []*http.Request{ - &http.Request{ + { Method: "GET", Header: http.Header{ "Header": []string{"test"}, diff --git a/api/handler/http/http_test.go b/api/handler/http/http_test.go index 31847221..9812535c 100644 --- a/api/handler/http/http_test.go +++ b/api/handler/http/http_test.go @@ -27,7 +27,7 @@ func testHttp(t *testing.T, path, service, ns string) { s := ®istry.Service{ Name: service, Nodes: []*registry.Node{ - ®istry.Node{ + { Id: service + "-1", Address: l.Addr().String(), }, diff --git a/broker/common_test.go b/broker/common_test.go index 262a77eb..c01d42c7 100644 --- a/broker/common_test.go +++ b/broker/common_test.go @@ -7,7 +7,7 @@ import ( var ( // mock data testData = map[string][]*registry.Service{ - "foo": []*registry.Service{ + "foo": { { Name: "foo", Version: "1.0.0", diff --git a/broker/http_broker_test.go b/broker/http_broker_test.go index 4695033e..c3849ac6 100644 --- a/broker/http_broker_test.go +++ b/broker/http_broker_test.go @@ -125,7 +125,7 @@ func pub(be *testing.B, c int) { for i := 0; i < c; i++ { go func() { - for _ = range ch { + for range ch { if err := b.Publish(topic, msg); err != nil { be.Fatalf("Unexpected publish error: %v", err) } diff --git a/client/common_test.go b/client/common_test.go index 15ddc158..42d1ed87 100644 --- a/client/common_test.go +++ b/client/common_test.go @@ -7,7 +7,7 @@ import ( var ( // mock data testData = map[string][]*registry.Service{ - "foo": []*registry.Service{ + "foo": { { Name: "foo", Version: "1.0.0", diff --git a/client/grpc/grpc_test.go b/client/grpc/grpc_test.go index 5696a267..e437c0ef 100644 --- a/client/grpc/grpc_test.go +++ b/client/grpc/grpc_test.go @@ -42,7 +42,7 @@ func TestGRPCClient(t *testing.T) { Name: "helloworld", Version: "test", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test-1", Address: l.Addr().String(), }, diff --git a/client/rpc_client_test.go b/client/rpc_client_test.go index 14547e9f..88cd08d8 100644 --- a/client/rpc_client_test.go +++ b/client/rpc_client_test.go @@ -143,7 +143,7 @@ func TestCallWrapper(t *testing.T) { Name: service, Version: "latest", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: id, Address: address, }, diff --git a/client/selector/common_test.go b/client/selector/common_test.go index 7aba0542..1af55c1c 100644 --- a/client/selector/common_test.go +++ b/client/selector/common_test.go @@ -7,7 +7,7 @@ import ( var ( // mock data testData = map[string][]*registry.Service{ - "foo": []*registry.Service{ + "foo": { { Name: "foo", Version: "1.0.0", diff --git a/client/selector/dns/dns.go b/client/selector/dns/dns.go index df6c209f..4248fe3d 100644 --- a/client/selector/dns/dns.go +++ b/client/selector/dns/dns.go @@ -72,7 +72,7 @@ func (d *dnsSelector) Select(service string, opts ...selector.SelectOption) (sel } services := []*registry.Service{ - ®istry.Service{ + { Name: service, Nodes: nodes, }, diff --git a/client/selector/filter_test.go b/client/selector/filter_test.go index 5a3e9c0d..035feed3 100644 --- a/client/selector/filter_test.go +++ b/client/selector/filter_test.go @@ -14,20 +14,20 @@ func TestFilterEndpoint(t *testing.T) { }{ { services: []*registry.Service{ - ®istry.Service{ + { Name: "test", Version: "1.0.0", Endpoints: []*registry.Endpoint{ - ®istry.Endpoint{ + { Name: "Foo.Bar", }, }, }, - ®istry.Service{ + { Name: "test", Version: "1.1.0", Endpoints: []*registry.Endpoint{ - ®istry.Endpoint{ + { Name: "Baz.Bar", }, }, @@ -38,20 +38,20 @@ func TestFilterEndpoint(t *testing.T) { }, { services: []*registry.Service{ - ®istry.Service{ + { Name: "test", Version: "1.0.0", Endpoints: []*registry.Endpoint{ - ®istry.Endpoint{ + { Name: "Foo.Bar", }, }, }, - ®istry.Service{ + { Name: "test", Version: "1.1.0", Endpoints: []*registry.Endpoint{ - ®istry.Endpoint{ + { Name: "Foo.Bar", }, }, @@ -95,11 +95,11 @@ func TestFilterLabel(t *testing.T) { }{ { services: []*registry.Service{ - ®istry.Service{ + { Name: "test", Version: "1.0.0", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test-1", Address: "localhost", Metadata: map[string]string{ @@ -108,11 +108,11 @@ func TestFilterLabel(t *testing.T) { }, }, }, - ®istry.Service{ + { Name: "test", Version: "1.1.0", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test-2", Address: "localhost", Metadata: map[string]string{ @@ -127,21 +127,21 @@ func TestFilterLabel(t *testing.T) { }, { services: []*registry.Service{ - ®istry.Service{ + { Name: "test", Version: "1.0.0", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test-1", Address: "localhost", }, }, }, - ®istry.Service{ + { Name: "test", Version: "1.1.0", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test-2", Address: "localhost", }, @@ -187,11 +187,11 @@ func TestFilterVersion(t *testing.T) { }{ { services: []*registry.Service{ - ®istry.Service{ + { Name: "test", Version: "1.0.0", }, - ®istry.Service{ + { Name: "test", Version: "1.1.0", }, @@ -201,11 +201,11 @@ func TestFilterVersion(t *testing.T) { }, { services: []*registry.Service{ - ®istry.Service{ + { Name: "test", Version: "1.0.0", }, - ®istry.Service{ + { Name: "test", Version: "1.1.0", }, diff --git a/client/selector/strategy_test.go b/client/selector/strategy_test.go index 8ea9376a..2529a6b7 100644 --- a/client/selector/strategy_test.go +++ b/client/selector/strategy_test.go @@ -8,29 +8,29 @@ import ( func TestStrategies(t *testing.T) { testData := []*registry.Service{ - ®istry.Service{ + { Name: "test1", Version: "latest", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test1-1", Address: "10.0.0.1:1001", }, - ®istry.Node{ + { Id: "test1-2", Address: "10.0.0.2:1002", }, }, }, - ®istry.Service{ + { Name: "test1", Version: "default", Nodes: []*registry.Node{ - ®istry.Node{ + { Id: "test1-3", Address: "10.0.0.3:1003", }, - ®istry.Node{ + { Id: "test1-4", Address: "10.0.0.4:1004", }, diff --git a/common_test.go b/common_test.go index d4fd4bfb..6a1ed2d8 100644 --- a/common_test.go +++ b/common_test.go @@ -7,7 +7,7 @@ import ( var ( // mock data testData = map[string][]*registry.Service{ - "foo": []*registry.Service{ + "foo": { { Name: "foo", Version: "1.0.0", diff --git a/config/reader/json/values_test.go b/config/reader/json/values_test.go index 97aec68a..166d9ae0 100644 --- a/config/reader/json/values_test.go +++ b/config/reader/json/values_test.go @@ -62,7 +62,7 @@ func TestStructArray(t *testing.T) { { []byte(`[{"foo": "bar"}]`), emptyTSlice, - []T{T{Foo: "bar"}}, + []T{{Foo: "bar"}}, }, } diff --git a/errors/errors_test.go b/errors/errors_test.go index 5df084d2..757d275d 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -7,7 +7,7 @@ import ( func TestErrors(t *testing.T) { testData := []*Error{ - &Error{ + { Id: "test", Code: 500, Detail: "Internal server error", diff --git a/monitor/default.go b/monitor/default.go index a03a0b31..050f8335 100644 --- a/monitor/default.go +++ b/monitor/default.go @@ -140,7 +140,7 @@ func (m *monitor) reap() { defer m.Unlock() // range over our watched services - for service, _ := range m.services { + for service := range m.services { // check if the service exists in the registry if !serviceMap[service] { // if not, delete it in our status map @@ -195,14 +195,14 @@ func (m *monitor) run() { serviceMap := make(map[string]bool) m.RLock() - for service, _ := range m.services { + for service := range m.services { serviceMap[service] = true } m.RUnlock() go func() { // check the status of all watched services - for service, _ := range serviceMap { + for service := range serviceMap { select { case <-m.exit: return @@ -307,7 +307,7 @@ func (m *monitor) Stop() error { return nil default: close(m.exit) - for s, _ := range m.services { + for s := range m.services { delete(m.services, s) } m.registry.Stop() diff --git a/proxy/http/http.go b/proxy/http/http.go index 37ef1f87..0df61927 100644 --- a/proxy/http/http.go +++ b/proxy/http/http.go @@ -113,7 +113,7 @@ func (p *Proxy) ServeRequest(ctx context.Context, req server.Request, rsp server // set response headers hdr = map[string]string{} - for k, _ := range hrsp.Header { + for k := range hrsp.Header { hdr[k] = hrsp.Header.Get(k) } // write the header diff --git a/proxy/mucp/mucp.go b/proxy/mucp/mucp.go index 02ab381c..91c40bc0 100644 --- a/proxy/mucp/mucp.go +++ b/proxy/mucp/mucp.go @@ -228,7 +228,7 @@ func (p *Proxy) refreshMetrics() { // get a list of services to update p.RLock() - for service, _ := range p.Routes { + for service := range p.Routes { services = append(services, service) } p.RUnlock() diff --git a/registry/encoding_test.go b/registry/encoding_test.go index 89acd980..ff9ae97e 100644 --- a/registry/encoding_test.go +++ b/registry/encoding_test.go @@ -6,13 +6,13 @@ import ( func TestEncoding(t *testing.T) { testData := []*mdnsTxt{ - &mdnsTxt{ + { Version: "1.0.0", Metadata: map[string]string{ "foo": "bar", }, Endpoints: []*Endpoint{ - &Endpoint{ + { Name: "endpoint1", Request: &Value{ Name: "request", diff --git a/registry/mdns_test.go b/registry/mdns_test.go index e9813c69..bd544df9 100644 --- a/registry/mdns_test.go +++ b/registry/mdns_test.go @@ -7,11 +7,11 @@ import ( func TestMDNS(t *testing.T) { testData := []*Service{ - &Service{ + { Name: "test1", Version: "1.0.1", Nodes: []*Node{ - &Node{ + { Id: "test1-1", Address: "10.0.0.1:10001", Metadata: map[string]string{ @@ -20,11 +20,11 @@ func TestMDNS(t *testing.T) { }, }, }, - &Service{ + { Name: "test2", Version: "1.0.2", Nodes: []*Node{ - &Node{ + { Id: "test2-1", Address: "10.0.0.2:10002", Metadata: map[string]string{ @@ -33,11 +33,11 @@ func TestMDNS(t *testing.T) { }, }, }, - &Service{ + { Name: "test3", Version: "1.0.3", Nodes: []*Node{ - &Node{ + { Id: "test3-1", Address: "10.0.0.3:10003", Metadata: map[string]string{ diff --git a/registry/memory/memory_test.go b/registry/memory/memory_test.go index fa8b53f1..593122bf 100644 --- a/registry/memory/memory_test.go +++ b/registry/memory/memory_test.go @@ -8,7 +8,7 @@ import ( var ( testData = map[string][]*registry.Service{ - "foo": []*registry.Service{ + "foo": { { Name: "foo", Version: "1.0.0", @@ -44,7 +44,7 @@ var ( }, }, }, - "bar": []*registry.Service{ + "bar": { { Name: "bar", Version: "default", diff --git a/registry/watcher_test.go b/registry/watcher_test.go index 94c8c275..a564bcda 100644 --- a/registry/watcher_test.go +++ b/registry/watcher_test.go @@ -6,11 +6,11 @@ import ( func TestWatcher(t *testing.T) { testData := []*Service{ - &Service{ + { Name: "test1", Version: "1.0.1", Nodes: []*Node{ - &Node{ + { Id: "test1-1", Address: "10.0.0.1:10001", Metadata: map[string]string{ @@ -19,11 +19,11 @@ func TestWatcher(t *testing.T) { }, }, }, - &Service{ + { Name: "test2", Version: "1.0.2", Nodes: []*Node{ - &Node{ + { Id: "test2-1", Address: "10.0.0.2:10002", Metadata: map[string]string{ @@ -32,11 +32,11 @@ func TestWatcher(t *testing.T) { }, }, }, - &Service{ + { Name: "test3", Version: "1.0.3", Nodes: []*Node{ - &Node{ + { Id: "test3-1", Address: "10.0.0.3:10003", Metadata: map[string]string{ diff --git a/router/service/service.go b/router/service/service.go index 4f9dcb9b..3d95ab5b 100644 --- a/router/service/service.go +++ b/router/service/service.go @@ -230,7 +230,7 @@ func (s *svc) Solicit() error { // build events to advertise events := make([]*router.Event, len(routes)) - for i, _ := range events { + for i := range events { events[i] = &router.Event{ Type: router.Update, Timestamp: time.Now(), diff --git a/server/grpc/grpc.go b/server/grpc/grpc.go index 8da88b97..e037a0d1 100644 --- a/server/grpc/grpc.go +++ b/server/grpc/grpc.go @@ -621,7 +621,7 @@ func (g *grpcServer) Register() error { g.registered = true - for sb, _ := range g.subscribers { + for sb := range g.subscribers { handler := g.createSubHandler(sb, g.opts) var opts []broker.SubscribeOption if queue := sb.Options().Queue; len(queue) > 0 { diff --git a/server/rpc_server.go b/server/rpc_server.go index 89d60f9e..76687e30 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -531,7 +531,7 @@ func (s *rpcServer) Register() error { s.registered = true - for sb, _ := range s.subscribers { + for sb := range s.subscribers { handler := s.createSubHandler(sb, s.opts) var opts []broker.SubscribeOption if queue := sb.Options().Queue; len(queue) > 0 { diff --git a/tunnel/default.go b/tunnel/default.go index ae7b69fa..314ee908 100644 --- a/tunnel/default.go +++ b/tunnel/default.go @@ -590,7 +590,7 @@ func (t *tun) listen(link *link) { } // strip tunnel message header - for k, _ := range msg.Header { + for k := range msg.Header { if strings.HasPrefix(k, "Micro-Tunnel") { delete(msg.Header, k) } diff --git a/web/service.go b/web/service.go index 65359a2b..e0a7014e 100644 --- a/web/service.go +++ b/web/service.go @@ -82,7 +82,7 @@ func (s *service) genSrv() *registry.Service { return ®istry.Service{ Name: s.opts.Name, Version: s.opts.Version, - Nodes: []*registry.Node{®istry.Node{ + Nodes: []*registry.Node{{ Id: s.opts.Id, Address: fmt.Sprintf("%s:%d", addr, port), Metadata: s.opts.Metadata,