Passed
Push — main ( 8e8d23...7310eb )
by Clive
03:14
created

utils.CenterString   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
package utils
2
3
import "strings"
4
5
func CenterString(str string, width int) string {
6
	spaces := int(float64(width-len(str)) / 2)
7
	return strings.Repeat(" ", spaces) + str + strings.Repeat(" ", width-(spaces+len(str)))
8
}
9