Hey @golangworld, you can use a package such as https://github.com/tv42/base58 to encode and decode to and from base58
. This was the first package I found on the https://golanglibs.com website, but I’m sure there are other ones available too.
Here’s an example for you:
package main
import (
"fmt"
"log"
"github.com/tv42/base58"
)
func main() {
// Address.
addr := []byte("1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN")
// Encode addr to a big.Int.
bigInt, err := base58.DecodeToBig(addr)
if err != nil {
log.Fatalln(err)
}
// Print the big.Int value.
fmt.Println(bigInt)
// Decode the bigInt value back to an address value.
decoded := base58.EncodeBig(nil, bigInt)
// Print the decoded addr.
fmt.Printf("%s", decoded)
}