package humanizeimport ()func stripTrailingZeros( string) string {if !strings.ContainsRune(, '.') {return } := len() - 1for > 0 {if [] == '.' { --break }if [] != '0' {break } -- }return [:+1]}func stripTrailingDigits( string, int) string {if := strings.Index(, "."); >= 0 {if <= 0 {return [:] } ++if + >= len() {return }return [:+] }return}// Ftoa converts a float to a string with no trailing zeros.func ( float64) string {returnstripTrailingZeros(strconv.FormatFloat(, 'f', 6, 64))}// FtoaWithDigits converts a float to a string but limits the resulting string// to the given number of decimal places, and no trailing zeros.func ( float64, int) string {returnstripTrailingZeros(stripTrailingDigits(strconv.FormatFloat(, 'f', 6, 64), ))}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.