Skip to content

Commit

Permalink
style: modify declaring empty slices (#2378)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
demoManito committed Sep 27, 2022
1 parent faa3adc commit 0ecc2b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 2 additions & 5 deletions contrib/registry/eureka/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,9 @@ func (r *Registry) Watch(ctx context.Context, serviceName string) (registry.Watc
}

func (r *Registry) Endpoints(service *registry.ServiceInstance) []Endpoint {
var (
res = []Endpoint{}
start int
)
res := make([]Endpoint, 0, len(service.Endpoints))
for _, ep := range service.Endpoints {
start = strings.Index(ep, "//")
start := strings.Index(ep, "//")
end := strings.LastIndex(ep, ":")
appID := strings.ToUpper(service.Name)
ip := ep[start+2 : end]
Expand Down
10 changes: 6 additions & 4 deletions middleware/tracing/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ func setClientSpan(ctx context.Context, span trace.Span, m interface{}) {
}

func setServerSpan(ctx context.Context, span trace.Span, m interface{}) {
attrs := []attribute.KeyValue{}
var remote string
var operation string
var rpcKind string
var (
attrs []attribute.KeyValue
remote string
operation string
rpcKind string
)
tr, ok := transport.FromServerContext(ctx)
if ok {
operation = tr.Operation()
Expand Down

0 comments on commit 0ecc2b4

Please sign in to comment.