I am attempting to port some Python code over to Go.
In my Python code I do:
print(b"\x02" + (3).to_bytes(4, "big", signed=True))
This returns me []byte{0x2, 0x0, 0x0, 0x0, 0x3}
This adds 2 to the start of my byte array and then 3 on the end with a prefix of 3 0's.
In GO I'm doing
digest = append(digest, byte(0x02))
err := binary.Write(buf, binary.BigEndian, int64(3))
if err != nil {
return nil, err
}
digest = append(digest, buf.Bytes()...)
return digest
This returns []byte{0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3}
In Python I can choose the length which seems to be the issue, is there something similar in Go when converting an int to bytes?
Thanks!