How to remove trailing zeros from a string in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"strings"
)

func main() {
	str := "457833.8591000"

	str = strings.TrimRight(str, "0")

	fmt.Println(str)
}



/*
run:

457833.8591

*/

 



answered Nov 15, 2024 by avibootz

Related questions

2 answers 138 views
1 answer 124 views
3 answers 141 views
1 answer 97 views
1 answer 124 views
1 answer 118 views
...