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

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git