mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #111496 from HecarimV/unnecessary-fmt
Remove unnecessary use of fmt.Sprintf
This commit is contained in:
commit
da0091ceda
@ -27,9 +27,9 @@ func ShortHumanDuration(d time.Duration) string {
|
|||||||
// Allow deviation no more than 2 seconds(excluded) to tolerate machine time
|
// Allow deviation no more than 2 seconds(excluded) to tolerate machine time
|
||||||
// inconsistence, it can be considered as almost now.
|
// inconsistence, it can be considered as almost now.
|
||||||
if seconds := int(d.Seconds()); seconds < -1 {
|
if seconds := int(d.Seconds()); seconds < -1 {
|
||||||
return fmt.Sprintf("<invalid>")
|
return "<invalid>"
|
||||||
} else if seconds < 0 {
|
} else if seconds < 0 {
|
||||||
return fmt.Sprintf("0s")
|
return "0s"
|
||||||
} else if seconds < 60 {
|
} else if seconds < 60 {
|
||||||
return fmt.Sprintf("%ds", seconds)
|
return fmt.Sprintf("%ds", seconds)
|
||||||
} else if minutes := int(d.Minutes()); minutes < 60 {
|
} else if minutes := int(d.Minutes()); minutes < 60 {
|
||||||
@ -49,9 +49,9 @@ func HumanDuration(d time.Duration) string {
|
|||||||
// Allow deviation no more than 2 seconds(excluded) to tolerate machine time
|
// Allow deviation no more than 2 seconds(excluded) to tolerate machine time
|
||||||
// inconsistence, it can be considered as almost now.
|
// inconsistence, it can be considered as almost now.
|
||||||
if seconds := int(d.Seconds()); seconds < -1 {
|
if seconds := int(d.Seconds()); seconds < -1 {
|
||||||
return fmt.Sprintf("<invalid>")
|
return "<invalid>"
|
||||||
} else if seconds < 0 {
|
} else if seconds < 0 {
|
||||||
return fmt.Sprintf("0s")
|
return "0s"
|
||||||
} else if seconds < 60*2 {
|
} else if seconds < 60*2 {
|
||||||
return fmt.Sprintf("%ds", seconds)
|
return fmt.Sprintf("%ds", seconds)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ func (u responseUpgrader) UpgradeResponse(w http.ResponseWriter, req *http.Reque
|
|||||||
|
|
||||||
hijacker, ok := w.(http.Hijacker)
|
hijacker, ok := w.(http.Hijacker)
|
||||||
if !ok {
|
if !ok {
|
||||||
errorMsg := fmt.Sprintf("unable to upgrade: unable to hijack response")
|
errorMsg := "unable to upgrade: unable to hijack response"
|
||||||
http.Error(w, errorMsg, http.StatusInternalServerError)
|
http.Error(w, errorMsg, http.StatusInternalServerError)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -352,8 +352,8 @@ func TestEvaluateTypes(t *testing.T) {
|
|||||||
|
|
||||||
t.Run(fmt.Sprintf("%d_raw", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%d_raw", i), func(t *testing.T) {
|
||||||
// decode the input as a standalone object
|
// decode the input as a standalone object
|
||||||
inputJSON := fmt.Sprintf(`%s`, tc.In)
|
inputJSON := tc.In
|
||||||
expectedJSON := fmt.Sprintf(`%s`, tc.Out)
|
expectedJSON := tc.Out
|
||||||
var m interface{}
|
var m interface{}
|
||||||
err := Unmarshal([]byte(inputJSON), &m)
|
err := Unmarshal([]byte(inputJSON), &m)
|
||||||
if tc.Err && err != nil {
|
if tc.Err && err != nil {
|
||||||
|
@ -142,7 +142,7 @@ func GetCaller() string {
|
|||||||
runtime.Callers(3, pc[:])
|
runtime.Callers(3, pc[:])
|
||||||
f := runtime.FuncForPC(pc[0])
|
f := runtime.FuncForPC(pc[0])
|
||||||
if f == nil {
|
if f == nil {
|
||||||
return fmt.Sprintf("Unable to find caller")
|
return "Unable to find caller"
|
||||||
}
|
}
|
||||||
return f.Name()
|
return f.Name()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user