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 125 views
1 answer 111 views
3 answers 130 views
1 answer 86 views
1 answer 116 views
1 answer 107 views
...