Golang encoding/base32.Encoding.DecodedLen function example
package encoding/base32
DecodedLen returns the maximum length in bytes of the decoded data corresponding to n bytes of base32-encoded data.
Golang encoding/base32.Encoding.DecodedLen function usage example
func packBase32(s []byte) ([]byte, error) {
b32len := base32.HexEncoding.DecodedLen(len(s)) // <---- DecodedLen()
buf := make([]byte, b32len)
n, err := base32.HexEncoding.Decode(buf, []byte(s))
if err != nil {
return nil, err
}
buf = buf[:n]
return buf, nil
}
References :
Advertisement
Something interesting
Tutorials
+7.8k Golang : Getting Echo framework StartAutoTLS to work
+13.6k Golang : Strings comparison
+16.5k Golang : Get IP addresses of a domain name
+11.5k CodeIgniter : Import Linkedin data
+12.8k Golang : Convert int(year) to time.Time type
+16.4k Golang : Send email and SMTP configuration example
+7.8k Golang : Lock executable to a specific machine with unique hash of the machine
+6k Golang : Function as an argument type example
+16.3k Golang : How to extract links from web page ?
+7.7k Gogland : Where to put source code files in package directory for rookie
+29.5k Golang : How to create new XML file ?