Skip to content

Commit

Permalink
Merge pull request etcd-io#16256 from gocurr/simplify_fmt_print
Browse files Browse the repository at this point in the history
etcdctl/ctlv3/command: simplify code using fmt.Printf with '\n'
  • Loading branch information
ahrtr authored Jul 18, 2023
2 parents 7aad281 + 223a75b commit eb204f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions etcdctl/ctlv3/command/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func newCheckDatascaleCommand(cmd *cobra.Command, args []string) {
os.Exit(cobrautl.ExitError)
}

fmt.Println(fmt.Sprintf("Start data scale check for work load [%v key-value pairs, %v bytes per key-value, %v concurrent clients].", cfg.limit, cfg.kvSize, cfg.clients))
fmt.Printf("Start data scale check for work load [%v key-value pairs, %v bytes per key-value, %v concurrent clients].\n", cfg.limit, cfg.kvSize, cfg.clients)
bar := pb.New(cfg.limit)
bar.Start()

Expand Down Expand Up @@ -435,6 +435,6 @@ func newCheckDatascaleCommand(cmd *cobra.Command, args []string) {
}
os.Exit(cobrautl.ExitError)
} else {
fmt.Println(fmt.Sprintf("PASS: Approximate system memory used : %v MB.", strconv.FormatFloat(mbUsed, 'f', 2, 64)))
fmt.Printf("PASS: Approximate system memory used : %v MB.\n", strconv.FormatFloat(mbUsed, 'f', 2, 64))
}
}
10 changes: 5 additions & 5 deletions etcdctl/ctlv3/command/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func endpointMemoryMetrics(host string, scfg *clientv3.SecureConfig) float64 {
// load client certificate
cert, err := tls.LoadX509KeyPair(scfg.Cert, scfg.Key)
if err != nil {
fmt.Println(fmt.Sprintf("client certificate error: %v", err))
fmt.Printf("client certificate error: %v\n", err)
return 0.0
}
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
Expand All @@ -114,13 +114,13 @@ func endpointMemoryMetrics(host string, scfg *clientv3.SecureConfig) float64 {
}
resp, err := http.Get(url)
if err != nil {
fmt.Println(fmt.Sprintf("fetch error: %v", err))
fmt.Printf("fetch error: %v\n", err)
return 0.0
}
byts, readerr := io.ReadAll(resp.Body)
resp.Body.Close()
if readerr != nil {
fmt.Println(fmt.Sprintf("fetch error: reading %s: %v", url, readerr))
fmt.Printf("fetch error: reading %s: %v\n", url, readerr)
return 0.0
}

Expand All @@ -131,12 +131,12 @@ func endpointMemoryMetrics(host string, scfg *clientv3.SecureConfig) float64 {
}
}
if residentMemoryValue == "" {
fmt.Println(fmt.Sprintf("could not find: %v", residentMemoryKey))
fmt.Printf("could not find: %v\n", residentMemoryKey)
return 0.0
}
residentMemoryBytes, parseErr := strconv.ParseFloat(residentMemoryValue, 64)
if parseErr != nil {
fmt.Println(fmt.Sprintf("parse error: %v", parseErr))
fmt.Printf("parse error: %v\n", parseErr)
return 0.0
}

Expand Down

0 comments on commit eb204f1

Please sign in to comment.