To make sure we won't overflow, we need math/big from Go
inputString := "Ag==" // base64'd byte representation of number 2 // first base64 -> bytes decodedBytes, _ := b64.StdEncoding.DecodeString(inputString) // bytes -> big.Int bigInt := new(big.Int) bigInt.SetBytes(decodedBytes) resultInt64 := bigInt.Int64() // == int64(2) resultInt := int(resultInt64) // == int(2)
Top comments (0)