Kevin Wan преди 3 години
родител
ревизия
9c1ee50497
променени са 4 файла, в които са добавени 10 реда и са изтрити 5 реда
  1. 2 1
      core/trace/constants.go
  2. 1 1
      rest/handler/tracinghandler.go
  3. 2 2
      rest/handler/tracinghandler_test.go
  4. 5 1
      tools/goctl/rpc/generator/gencall.go

+ 2 - 1
core/trace/constants.go

@@ -2,5 +2,6 @@ package trace
 
 const (
 	TraceIdKey = "X-Trace-ID"
-	spanIdKey  = "X-Span-ID"
+
+	spanIdKey = "X-Span-ID"
 )

+ 1 - 1
rest/handler/tracinghandler.go

@@ -21,7 +21,7 @@ func TracingHandler(next http.Handler) http.Handler {
 		defer span.Finish()
 		r = r.WithContext(ctx)
 
-		// Conveniently track error messages
+		// conveniently tracking error messages
 		w.Header().Set(trace.TraceIdKey, span.TraceId())
 		next.ServeHTTP(w, r)
 	})

+ 2 - 2
rest/handler/tracinghandler_test.go

@@ -1,13 +1,13 @@
 package handler
 
 import (
-	"github.com/tal-tech/go-zero/core/stringx"
-	"github.com/tal-tech/go-zero/core/trace"
 	"net/http"
 	"net/http/httptest"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
+	"github.com/tal-tech/go-zero/core/stringx"
+	"github.com/tal-tech/go-zero/core/trace"
 	"github.com/tal-tech/go-zero/core/trace/tracespec"
 )
 

+ 5 - 1
tools/goctl/rpc/generator/gencall.go

@@ -109,7 +109,8 @@ func (g *DefaultGenerator) GenCall(ctx DirContext, proto parser.Proto, cfg *conf
 }
 
 func getMessageName(msg proto.Message) string {
-	var list = []string{msg.Name}
+	list := []string{msg.Name}
+
 	for {
 		parent := msg.Parent
 		if parent == nil {
@@ -125,11 +126,13 @@ func getMessageName(msg proto.Message) string {
 		list = append(tmp, list...)
 		msg = *parentMsg
 	}
+
 	return strings.Join(list, "_")
 }
 
 func (g *DefaultGenerator) genFunction(goPackage string, service parser.Service) ([]string, error) {
 	functions := make([]string, 0)
+
 	for _, rpc := range service.RPC {
 		text, err := util.LoadTemplate(category, callFunctionTemplateFile, callFunctionTemplate)
 		if err != nil {
@@ -157,6 +160,7 @@ func (g *DefaultGenerator) genFunction(goPackage string, service parser.Service)
 
 		functions = append(functions, buffer.String())
 	}
+
 	return functions, nil
 }