DEV Community

Tomasz Giba
Tomasz Giba

Posted on • Updated on


How get int from base64'd number bytes representation in Go

To make sure we won't overflow, we need math/big from Go

inputString := "Ag==" // base64'd byte representation of number 2

// first base64 -> bytes 
decodedBytes, _ := b64.StdEncoding.DecodeString(inputString)

// bytes -> big.Int
bigInt := new(big.Int)

resultInt64 := bigInt.Int64() // == int64(2)
resultInt := int(resultInt64) // == int(2)
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)

An Animated Guide to Node.js Event Loop

Node.js doesn’t stop from running other operations because of Libuv, a C++ library responsible for the event loop and asynchronously handling tasks such as network requests, DNS resolution, file system operations, data encryption, etc.

What happens under the hood when Node.js works on tasks such as database queries? We will explore it by following this piece of code step by step.