Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created May 12, 2023 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/b542fa5fc9f034aaacdda5fe841a16ba to your computer and use it in GitHub Desktop.
Save miguelmota/b542fa5fc9f034aaacdda5fe841a16ba to your computer and use it in GitHub Desktop.
Go golang uint64 to bytes, bytes to uint64
// You can edit this code!
// Click here and start typing.
package main
import (
"fmt"
"math/big"
)
func main() {
b := new(big.Int)
b.SetUint64(1337)
v := b.Bytes()
fmt.Println(v)
n := int(big.NewInt(0).SetBytes(v).Uint64())
fmt.Println(n)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment