Browse code

Correct fmt.Fprintf and t.Fatalf

Signed-off-by: Helen Xie <chenjg@harmonycloud.cn>

fate-grand-order authored on 2017/02/08 12:22:21
Showing 2 changed files
... ...
@@ -29,13 +29,13 @@ func profilerSetup(mainRouter *mux.Router) {
29 29
 func expVars(w http.ResponseWriter, r *http.Request) {
30 30
 	first := true
31 31
 	w.Header().Set("Content-Type", "application/json; charset=utf-8")
32
-	fmt.Fprintf(w, "{\n")
32
+	fmt.Fprintln(w, "{")
33 33
 	expvar.Do(func(kv expvar.KeyValue) {
34 34
 		if !first {
35
-			fmt.Fprintf(w, ",\n")
35
+			fmt.Fprintln(w, ",")
36 36
 		}
37 37
 		first = false
38 38
 		fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value)
39 39
 	})
40
-	fmt.Fprintf(w, "\n}\n")
40
+	fmt.Fprintln(w, "\n}")
41 41
 }
... ...
@@ -29,7 +29,7 @@ func TestMiddlewares(t *testing.T) {
29 29
 
30 30
 	localHandler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
31 31
 		if httputils.VersionFromContext(ctx) == "" {
32
-			t.Fatalf("Expected version, got empty string")
32
+			t.Fatal("Expected version, got empty string")
33 33
 		}
34 34
 
35 35
 		if sv := w.Header().Get("Server"); !strings.Contains(sv, "Docker/0.1omega2") {