blockchain-poc/utils.go

17 lines
272 B
Go
Raw Normal View History

2017-09-22 16:48:05 +00:00
package main
import (
"bytes"
"encoding/binary"
)
// IntToHex converts an int64 to a byte array
func IntToHex(num int64) []byte {
buf := new(bytes.Buffer)
err := binary.Write(buf, binary.BigEndian, num)
if err != nil {
2017-09-22 19:22:11 +00:00
exitWithError(err)
2017-09-22 16:48:05 +00:00
}
return buf.Bytes()
}