diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-09 16:29:25 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-14 08:52:28 +0300 |
commit | e566589b930fce5eeb8d1bc4c89fd9e196fb5b3b (patch) | |
tree | 7459b3b92a3471f2ed4bbc7f93b372c903b1373c | |
parent | ac48a410955889637f1d0fa98ac102ab3b9ea088 (diff) |
stats: Let callers append newlines for `printInteractive()`
When `printInteractive()` is called, the assumption is that all lines
should be terminated by a newline. While that's true right now, this
assumption keeps us from using this function in other places which thus
need to manually check whether the `interactive` flag is set.
Do not append the newline in `printInteractive()` and adjust callers
accordingly to prepare for wider use of that function.
-rw-r--r-- | internal/git/stats/analyzehttp.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/internal/git/stats/analyzehttp.go b/internal/git/stats/analyzehttp.go index 95144afa8..7538554e0 100644 --- a/internal/git/stats/analyzehttp.go +++ b/internal/git/stats/analyzehttp.go @@ -82,9 +82,9 @@ func (cl *Clone) doGet(ctx context.Context) error { } cl.Get.start = time.Now() - cl.printInteractive("---") - cl.printInteractive("--- GET %v", req.URL) - cl.printInteractive("---") + cl.printInteractive("---\n") + cl.printInteractive("--- GET %v\n", req.URL) + cl.printInteractive("---\n") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -101,8 +101,8 @@ func (cl *Clone) doGet(ctx context.Context) error { cl.Get.responseHeader = time.Since(cl.Get.start) cl.Get.httpStatus = resp.StatusCode - cl.printInteractive("response code: %d", resp.StatusCode) - cl.printInteractive("response header: %v", resp.Header) + cl.printInteractive("response code: %d\n", resp.StatusCode) + cl.printInteractive("response header: %v\n", resp.Header) body := resp.Body if resp.Header.Get("Content-Encoding") == "gzip" { @@ -214,9 +214,9 @@ func (cl *Clone) doPost(ctx context.Context) error { } cl.Post.start = time.Now() - cl.printInteractive("---") - cl.printInteractive("--- POST %v", req.URL) - cl.printInteractive("---") + cl.printInteractive("---\n") + cl.printInteractive("--- POST %v\n", req.URL) + cl.printInteractive("---\n") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -230,8 +230,8 @@ func (cl *Clone) doPost(ctx context.Context) error { cl.Post.responseHeader = time.Since(cl.Post.start) cl.Post.httpStatus = resp.StatusCode - cl.printInteractive("response code: %d", resp.StatusCode) - cl.printInteractive("response header: %v", resp.Header) + cl.printInteractive("response code: %d\n", resp.StatusCode) + cl.printInteractive("response header: %v\n", resp.Header) // Expected response: // - "NAK\n" @@ -329,7 +329,7 @@ func (cl *Clone) printInteractive(format string, a ...interface{}) { // Ignore any errors returned by this given that we only use it as a debugging aid // to write to stdout. - fmt.Printf(format+"\n", a...) + fmt.Printf(format, a...) } const ( |