import ( "fmt" "math/big" ) func main() { i := new(big.Int) i.SetString("123456789", 10) fmt.Println(i) // Output: 123456789 }
import ( "fmt" "math/big" ) func main() { i := new(big.Int) i.SetString("F00BAE", 16) fmt.Println(i) // Output: 15756462 }In both examples, we have used the SetString function to set an integer value by parsing a string in decimal and hexadecimal bases, respectively. The math/big package is a standard library package in Go.