Created
May 12, 2023 21:17
-
-
Save miguelmota/b542fa5fc9f034aaacdda5fe841a16ba to your computer and use it in GitHub Desktop.
Go golang uint64 to bytes, bytes to uint64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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