go - Acessing unexported function `nat.string` -


i want convert big.int simple base32. not standard base32 stuff rfc 4648 implemented base32 nor zbase32 nor crockford want simple normal 5-bits per character 0-9a-v character set.

i aware of base32 package , not want - builds result in standard base 32 number padding , stuff don't want. use , tear off trailing "=" characters , hack remains seems brutal solution.

there big.setstring(string, base) can parse base32 number in string form there no reverse - looking for, big.getstring(base) java biginteger.tostring(int base).

there is, however, nat.string exactly want. how can gain access it?

is there way manually extend big implement big.getstring(base) trivially calls nat.string correct charset?

is there way can reach unexported big.nat big uses , call nat.string?

is there else can do?

p.s. i'd interested in using nat.trailingzerobits - had write own because didn't realise done.

you can't access unexported functions @ all. you'd need re-write @ least portion of nat.go in order achieve functionality. of functions useful, may worth sending feature request golang-nuts group asking of them exported in future release.

you can use strconv.formatint() require.

given big.int b can do:

strconv.formatint(b.int64(), 32) 

full example:

package main  import (     "fmt"     "math/big"     "strconv" )  func main() {     := 3286583923486565782 // random integer     b := big.newint(int64(i))     fmt.println(strconv.formatint(b.int64(), 32)) } 

produces:

2r72al99uq9cm

playground


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -