I need help
Debezium(https://debezium.io/) convert decimal digits as integer in base64 string with precision as parameter in json In java it decoded like this example
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Base64;
public class HelloWorld{
public static void main(String []args){
String encoded = "lTBA";
int scale = 4;
final BigDecimal decoded = new BigDecimal(new BigInteger(Base64.getDecoder().decode(encoded)), scale);
System.out.println(decoded);
}
}
"lTBA" = -700
but in Golang I have some troubles in similar example
package main
import (
"encoding/base64"
"fmt"
"math/big"
)
func main() {
data, _ := base64.StdEncoding.DecodeString("lTBA")
bigInt := new(big.Int).SetBytes(data).String()
fmt.Println(bigInt)
}
https://play.golang.org/p/3Xdq9x6B9V-
It returns 9777216
Because when I use SetBytes in "math/big/Int" it set digit as positive always
// SetBytes interprets buf as the bytes of a big-endian unsigned
// integer, sets z to that value, and returns z.
func (z *Int) SetBytes(buf []byte) *Int {
z.abs = z.abs.setBytes(buf)
z.neg = false
return z
}