Golang : Convert(cast) bigint to string
Problem :
You want to convert(cast) a big integer value to string for display.
Solution :
Use big.Int.String() function to convert the big integer value to string. For example :
package main
import (
"fmt"
"math/big"
)
func main() {
bigInt := big.NewInt(123456789)
bigStr := bigInt.String()
fmt.Println(bigStr)
}
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+6k Golang : Function as an argument type example
+10k Golang : Convert octal value to string to deal with leading zero problem
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+12.4k Golang : Validate email address
+47.8k Golang : Convert int to byte array([]byte)
+17k Golang : Set up source IP address before making HTTP request
+12.6k Golang : flag provided but not defined error
+16.8k Golang : Gzip file example
+15.2k Golang : Get HTTP protocol version example
+25.7k Golang : How to write CSV data to file
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+5.6k PHP : Fix Call to undefined function curl_init() error