style: modify declaring empty slices (#2378)

* fix: modify declaring empty slices

declare an empty slice to var s []int replace s :=[]int{}, https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices

* fix lint
pull/2408/head
jesse.tang 2 years ago committed by GitHub
parent faa3adc300
commit 0ecc2b422f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      contrib/registry/eureka/register.go
  2. 10
      middleware/tracing/span.go

@ -92,12 +92,9 @@ func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watc
} }
func (r *Registry) Endpoints(service *registry.ServiceInstance) []Endpoint { func (r *Registry) Endpoints(service *registry.ServiceInstance) []Endpoint {
var ( res := make([]Endpoint, 0, len(service.Endpoints))
res = []Endpoint{}
start int
)
for _, ep := range service.Endpoints { for _, ep := range service.Endpoints {
start = strings.Index(ep, "//") start := strings.Index(ep, "//")
end := strings.LastIndex(ep, ":") end := strings.LastIndex(ep, ":")
appID := strings.ToUpper(service.Name) appID := strings.ToUpper(service.Name)
ip := ep[start+2 : end] ip := ep[start+2 : end]

@ -57,10 +57,12 @@ func setClientSpan(ctx context.Context, span trace.Span, m interface{}) {
} }
func setServerSpan(ctx context.Context, span trace.Span, m interface{}) { func setServerSpan(ctx context.Context, span trace.Span, m interface{}) {
attrs := []attribute.KeyValue{} var (
var remote string attrs []attribute.KeyValue
var operation string remote string
var rpcKind string operation string
rpcKind string
)
tr, ok := transport.FromServerContext(ctx) tr, ok := transport.FromServerContext(ctx)
if ok { if ok {
operation = tr.Operation() operation = tr.Operation()

Loading…
Cancel
Save