used gofmt with -s flag on whole project

This commit is contained in:
tegk 2019-11-01 15:07:53 +00:00
parent 0aa01b2ebf
commit f88518d994
26 changed files with 65 additions and 65 deletions

View File

@ -8,7 +8,7 @@ import (
func TestRequestToProto(t *testing.T) { func TestRequestToProto(t *testing.T) {
testData := []*http.Request{ testData := []*http.Request{
&http.Request{ {
Method: "GET", Method: "GET",
Header: http.Header{ Header: http.Header{
"Header": []string{"test"}, "Header": []string{"test"},

View File

@ -27,7 +27,7 @@ func testHttp(t *testing.T, path, service, ns string) {
s := &registry.Service{ s := &registry.Service{
Name: service, Name: service,
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: service + "-1", Id: service + "-1",
Address: l.Addr().String(), Address: l.Addr().String(),
}, },

View File

@ -7,7 +7,7 @@ import (
var ( var (
// mock data // mock data
testData = map[string][]*registry.Service{ testData = map[string][]*registry.Service{
"foo": []*registry.Service{ "foo": {
{ {
Name: "foo", Name: "foo",
Version: "1.0.0", Version: "1.0.0",

View File

@ -125,7 +125,7 @@ func pub(be *testing.B, c int) {
for i := 0; i < c; i++ { for i := 0; i < c; i++ {
go func() { go func() {
for _ = range ch { for range ch {
if err := b.Publish(topic, msg); err != nil { if err := b.Publish(topic, msg); err != nil {
be.Fatalf("Unexpected publish error: %v", err) be.Fatalf("Unexpected publish error: %v", err)
} }

View File

@ -7,7 +7,7 @@ import (
var ( var (
// mock data // mock data
testData = map[string][]*registry.Service{ testData = map[string][]*registry.Service{
"foo": []*registry.Service{ "foo": {
{ {
Name: "foo", Name: "foo",
Version: "1.0.0", Version: "1.0.0",

View File

@ -42,7 +42,7 @@ func TestGRPCClient(t *testing.T) {
Name: "helloworld", Name: "helloworld",
Version: "test", Version: "test",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test-1", Id: "test-1",
Address: l.Addr().String(), Address: l.Addr().String(),
}, },

View File

@ -143,7 +143,7 @@ func TestCallWrapper(t *testing.T) {
Name: service, Name: service,
Version: "latest", Version: "latest",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: id, Id: id,
Address: address, Address: address,
}, },

View File

@ -7,7 +7,7 @@ import (
var ( var (
// mock data // mock data
testData = map[string][]*registry.Service{ testData = map[string][]*registry.Service{
"foo": []*registry.Service{ "foo": {
{ {
Name: "foo", Name: "foo",
Version: "1.0.0", Version: "1.0.0",

View File

@ -72,7 +72,7 @@ func (d *dnsSelector) Select(service string, opts ...selector.SelectOption) (sel
} }
services := []*registry.Service{ services := []*registry.Service{
&registry.Service{ {
Name: service, Name: service,
Nodes: nodes, Nodes: nodes,
}, },

View File

@ -14,20 +14,20 @@ func TestFilterEndpoint(t *testing.T) {
}{ }{
{ {
services: []*registry.Service{ services: []*registry.Service{
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.0.0", Version: "1.0.0",
Endpoints: []*registry.Endpoint{ Endpoints: []*registry.Endpoint{
&registry.Endpoint{ {
Name: "Foo.Bar", Name: "Foo.Bar",
}, },
}, },
}, },
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.1.0", Version: "1.1.0",
Endpoints: []*registry.Endpoint{ Endpoints: []*registry.Endpoint{
&registry.Endpoint{ {
Name: "Baz.Bar", Name: "Baz.Bar",
}, },
}, },
@ -38,20 +38,20 @@ func TestFilterEndpoint(t *testing.T) {
}, },
{ {
services: []*registry.Service{ services: []*registry.Service{
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.0.0", Version: "1.0.0",
Endpoints: []*registry.Endpoint{ Endpoints: []*registry.Endpoint{
&registry.Endpoint{ {
Name: "Foo.Bar", Name: "Foo.Bar",
}, },
}, },
}, },
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.1.0", Version: "1.1.0",
Endpoints: []*registry.Endpoint{ Endpoints: []*registry.Endpoint{
&registry.Endpoint{ {
Name: "Foo.Bar", Name: "Foo.Bar",
}, },
}, },
@ -95,11 +95,11 @@ func TestFilterLabel(t *testing.T) {
}{ }{
{ {
services: []*registry.Service{ services: []*registry.Service{
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.0.0", Version: "1.0.0",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test-1", Id: "test-1",
Address: "localhost", Address: "localhost",
Metadata: map[string]string{ Metadata: map[string]string{
@ -108,11 +108,11 @@ func TestFilterLabel(t *testing.T) {
}, },
}, },
}, },
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.1.0", Version: "1.1.0",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test-2", Id: "test-2",
Address: "localhost", Address: "localhost",
Metadata: map[string]string{ Metadata: map[string]string{
@ -127,21 +127,21 @@ func TestFilterLabel(t *testing.T) {
}, },
{ {
services: []*registry.Service{ services: []*registry.Service{
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.0.0", Version: "1.0.0",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test-1", Id: "test-1",
Address: "localhost", Address: "localhost",
}, },
}, },
}, },
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.1.0", Version: "1.1.0",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test-2", Id: "test-2",
Address: "localhost", Address: "localhost",
}, },
@ -187,11 +187,11 @@ func TestFilterVersion(t *testing.T) {
}{ }{
{ {
services: []*registry.Service{ services: []*registry.Service{
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.0.0", Version: "1.0.0",
}, },
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.1.0", Version: "1.1.0",
}, },
@ -201,11 +201,11 @@ func TestFilterVersion(t *testing.T) {
}, },
{ {
services: []*registry.Service{ services: []*registry.Service{
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.0.0", Version: "1.0.0",
}, },
&registry.Service{ {
Name: "test", Name: "test",
Version: "1.1.0", Version: "1.1.0",
}, },

View File

@ -8,29 +8,29 @@ import (
func TestStrategies(t *testing.T) { func TestStrategies(t *testing.T) {
testData := []*registry.Service{ testData := []*registry.Service{
&registry.Service{ {
Name: "test1", Name: "test1",
Version: "latest", Version: "latest",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test1-1", Id: "test1-1",
Address: "10.0.0.1:1001", Address: "10.0.0.1:1001",
}, },
&registry.Node{ {
Id: "test1-2", Id: "test1-2",
Address: "10.0.0.2:1002", Address: "10.0.0.2:1002",
}, },
}, },
}, },
&registry.Service{ {
Name: "test1", Name: "test1",
Version: "default", Version: "default",
Nodes: []*registry.Node{ Nodes: []*registry.Node{
&registry.Node{ {
Id: "test1-3", Id: "test1-3",
Address: "10.0.0.3:1003", Address: "10.0.0.3:1003",
}, },
&registry.Node{ {
Id: "test1-4", Id: "test1-4",
Address: "10.0.0.4:1004", Address: "10.0.0.4:1004",
}, },

View File

@ -7,7 +7,7 @@ import (
var ( var (
// mock data // mock data
testData = map[string][]*registry.Service{ testData = map[string][]*registry.Service{
"foo": []*registry.Service{ "foo": {
{ {
Name: "foo", Name: "foo",
Version: "1.0.0", Version: "1.0.0",

View File

@ -62,7 +62,7 @@ func TestStructArray(t *testing.T) {
{ {
[]byte(`[{"foo": "bar"}]`), []byte(`[{"foo": "bar"}]`),
emptyTSlice, emptyTSlice,
[]T{T{Foo: "bar"}}, []T{{Foo: "bar"}},
}, },
} }

View File

@ -7,7 +7,7 @@ import (
func TestErrors(t *testing.T) { func TestErrors(t *testing.T) {
testData := []*Error{ testData := []*Error{
&Error{ {
Id: "test", Id: "test",
Code: 500, Code: 500,
Detail: "Internal server error", Detail: "Internal server error",

View File

@ -140,7 +140,7 @@ func (m *monitor) reap() {
defer m.Unlock() defer m.Unlock()
// range over our watched services // range over our watched services
for service, _ := range m.services { for service := range m.services {
// check if the service exists in the registry // check if the service exists in the registry
if !serviceMap[service] { if !serviceMap[service] {
// if not, delete it in our status map // if not, delete it in our status map
@ -195,14 +195,14 @@ func (m *monitor) run() {
serviceMap := make(map[string]bool) serviceMap := make(map[string]bool)
m.RLock() m.RLock()
for service, _ := range m.services { for service := range m.services {
serviceMap[service] = true serviceMap[service] = true
} }
m.RUnlock() m.RUnlock()
go func() { go func() {
// check the status of all watched services // check the status of all watched services
for service, _ := range serviceMap { for service := range serviceMap {
select { select {
case <-m.exit: case <-m.exit:
return return
@ -307,7 +307,7 @@ func (m *monitor) Stop() error {
return nil return nil
default: default:
close(m.exit) close(m.exit)
for s, _ := range m.services { for s := range m.services {
delete(m.services, s) delete(m.services, s)
} }
m.registry.Stop() m.registry.Stop()

View File

@ -113,7 +113,7 @@ func (p *Proxy) ServeRequest(ctx context.Context, req server.Request, rsp server
// set response headers // set response headers
hdr = map[string]string{} hdr = map[string]string{}
for k, _ := range hrsp.Header { for k := range hrsp.Header {
hdr[k] = hrsp.Header.Get(k) hdr[k] = hrsp.Header.Get(k)
} }
// write the header // write the header

View File

@ -228,7 +228,7 @@ func (p *Proxy) refreshMetrics() {
// get a list of services to update // get a list of services to update
p.RLock() p.RLock()
for service, _ := range p.Routes { for service := range p.Routes {
services = append(services, service) services = append(services, service)
} }
p.RUnlock() p.RUnlock()

View File

@ -6,13 +6,13 @@ import (
func TestEncoding(t *testing.T) { func TestEncoding(t *testing.T) {
testData := []*mdnsTxt{ testData := []*mdnsTxt{
&mdnsTxt{ {
Version: "1.0.0", Version: "1.0.0",
Metadata: map[string]string{ Metadata: map[string]string{
"foo": "bar", "foo": "bar",
}, },
Endpoints: []*Endpoint{ Endpoints: []*Endpoint{
&Endpoint{ {
Name: "endpoint1", Name: "endpoint1",
Request: &Value{ Request: &Value{
Name: "request", Name: "request",

View File

@ -7,11 +7,11 @@ import (
func TestMDNS(t *testing.T) { func TestMDNS(t *testing.T) {
testData := []*Service{ testData := []*Service{
&Service{ {
Name: "test1", Name: "test1",
Version: "1.0.1", Version: "1.0.1",
Nodes: []*Node{ Nodes: []*Node{
&Node{ {
Id: "test1-1", Id: "test1-1",
Address: "10.0.0.1:10001", Address: "10.0.0.1:10001",
Metadata: map[string]string{ Metadata: map[string]string{
@ -20,11 +20,11 @@ func TestMDNS(t *testing.T) {
}, },
}, },
}, },
&Service{ {
Name: "test2", Name: "test2",
Version: "1.0.2", Version: "1.0.2",
Nodes: []*Node{ Nodes: []*Node{
&Node{ {
Id: "test2-1", Id: "test2-1",
Address: "10.0.0.2:10002", Address: "10.0.0.2:10002",
Metadata: map[string]string{ Metadata: map[string]string{
@ -33,11 +33,11 @@ func TestMDNS(t *testing.T) {
}, },
}, },
}, },
&Service{ {
Name: "test3", Name: "test3",
Version: "1.0.3", Version: "1.0.3",
Nodes: []*Node{ Nodes: []*Node{
&Node{ {
Id: "test3-1", Id: "test3-1",
Address: "10.0.0.3:10003", Address: "10.0.0.3:10003",
Metadata: map[string]string{ Metadata: map[string]string{

View File

@ -8,7 +8,7 @@ import (
var ( var (
testData = map[string][]*registry.Service{ testData = map[string][]*registry.Service{
"foo": []*registry.Service{ "foo": {
{ {
Name: "foo", Name: "foo",
Version: "1.0.0", Version: "1.0.0",
@ -44,7 +44,7 @@ var (
}, },
}, },
}, },
"bar": []*registry.Service{ "bar": {
{ {
Name: "bar", Name: "bar",
Version: "default", Version: "default",

View File

@ -6,11 +6,11 @@ import (
func TestWatcher(t *testing.T) { func TestWatcher(t *testing.T) {
testData := []*Service{ testData := []*Service{
&Service{ {
Name: "test1", Name: "test1",
Version: "1.0.1", Version: "1.0.1",
Nodes: []*Node{ Nodes: []*Node{
&Node{ {
Id: "test1-1", Id: "test1-1",
Address: "10.0.0.1:10001", Address: "10.0.0.1:10001",
Metadata: map[string]string{ Metadata: map[string]string{
@ -19,11 +19,11 @@ func TestWatcher(t *testing.T) {
}, },
}, },
}, },
&Service{ {
Name: "test2", Name: "test2",
Version: "1.0.2", Version: "1.0.2",
Nodes: []*Node{ Nodes: []*Node{
&Node{ {
Id: "test2-1", Id: "test2-1",
Address: "10.0.0.2:10002", Address: "10.0.0.2:10002",
Metadata: map[string]string{ Metadata: map[string]string{
@ -32,11 +32,11 @@ func TestWatcher(t *testing.T) {
}, },
}, },
}, },
&Service{ {
Name: "test3", Name: "test3",
Version: "1.0.3", Version: "1.0.3",
Nodes: []*Node{ Nodes: []*Node{
&Node{ {
Id: "test3-1", Id: "test3-1",
Address: "10.0.0.3:10003", Address: "10.0.0.3:10003",
Metadata: map[string]string{ Metadata: map[string]string{

View File

@ -230,7 +230,7 @@ func (s *svc) Solicit() error {
// build events to advertise // build events to advertise
events := make([]*router.Event, len(routes)) events := make([]*router.Event, len(routes))
for i, _ := range events { for i := range events {
events[i] = &router.Event{ events[i] = &router.Event{
Type: router.Update, Type: router.Update,
Timestamp: time.Now(), Timestamp: time.Now(),

View File

@ -621,7 +621,7 @@ func (g *grpcServer) Register() error {
g.registered = true g.registered = true
for sb, _ := range g.subscribers { for sb := range g.subscribers {
handler := g.createSubHandler(sb, g.opts) handler := g.createSubHandler(sb, g.opts)
var opts []broker.SubscribeOption var opts []broker.SubscribeOption
if queue := sb.Options().Queue; len(queue) > 0 { if queue := sb.Options().Queue; len(queue) > 0 {

View File

@ -531,7 +531,7 @@ func (s *rpcServer) Register() error {
s.registered = true s.registered = true
for sb, _ := range s.subscribers { for sb := range s.subscribers {
handler := s.createSubHandler(sb, s.opts) handler := s.createSubHandler(sb, s.opts)
var opts []broker.SubscribeOption var opts []broker.SubscribeOption
if queue := sb.Options().Queue; len(queue) > 0 { if queue := sb.Options().Queue; len(queue) > 0 {

View File

@ -590,7 +590,7 @@ func (t *tun) listen(link *link) {
} }
// strip tunnel message header // strip tunnel message header
for k, _ := range msg.Header { for k := range msg.Header {
if strings.HasPrefix(k, "Micro-Tunnel") { if strings.HasPrefix(k, "Micro-Tunnel") {
delete(msg.Header, k) delete(msg.Header, k)
} }

View File

@ -82,7 +82,7 @@ func (s *service) genSrv() *registry.Service {
return &registry.Service{ return &registry.Service{
Name: s.opts.Name, Name: s.opts.Name,
Version: s.opts.Version, Version: s.opts.Version,
Nodes: []*registry.Node{&registry.Node{ Nodes: []*registry.Node{{
Id: s.opts.Id, Id: s.opts.Id,
Address: fmt.Sprintf("%s:%d", addr, port), Address: fmt.Sprintf("%s:%d", addr, port),
Metadata: s.opts.Metadata, Metadata: s.opts.Metadata,