```go
// get the amount of runes in the string instead of the
// character count of the string, as some runes span multiple characters.
// see https://stackoverflow.com/a/12668840/2733724
stringWidth := runewidth.StringWidth(cleanString)
return stringWidth
```
it use `github.com/mattn/go-runewidth` to calculate the width.
I checked the 'progress/ ansimeter. go', it is used the number of `rune`, rather than calculate the real width.
https:/ /github. com/snapcore/ snapd/blob/ master/ progress/ ansimeter. go#L150- L160
rpercent := []rune(percent) len(rpercent) -len(rspeed) -len(rtimeleft) , p.label)...)
rspeed := []rune(speed)
rtimeleft := []rune(timeleft)
msg := make([]rune, 0, col)
// XXX: assuming terminal can display `col` number of runes
msg = append(msg, norm(col-
msg = append(msg, rpercent...)
msg = append(msg, rspeed...)
msg = append(msg, rtimeleft...)
i := int(current * float64(col) / p.total)
fmt.Fprint(stdout, "\r", enterReverseMode, string(msg[:i]), exitAttributeMode, string(msg[i:]))
As a reference, here is how project 'schollz/ progressbar' calculating the width:
https:/ /github. com/schollz/ progressbar/ blob/master/ progressbar. go#L647- L651
```go /stackoverflow. com/a/12668840/ 2733724 StringWidth( cleanString)
// get the amount of runes in the string instead of the
// character count of the string, as some runes span multiple characters.
// see https:/
stringWidth := runewidth.
return stringWidth
```
it use `github. com/mattn/ go-runewidth` to calculate the width.