Golang encoding/hex.DecodedLen() function example
package encoding/hex
Return the size/length in bytes
Golang encoding/hex.DecodedLen() function usage example
package main
import (
"encoding/hex"
"fmt"
)
func main() {
str := "abcd"
fmt.Printf("Len size is : %v \n", len(str))
fmt.Printf("DecodedLen(count number of bytes) size is : %v \n", hex.DecodedLen(len(str)))
}
Output :
Len size is : 4
DecodedLen(count number of bytes) size is : 2
See https://www.socketloop.com/references/golang-encoding-hex-decode-function-example for more example on how DecodedLen() function is used.
References :
http://golang.org/pkg/encoding/hex/#DecodedLen
https://www.socketloop.com/references/golang-encoding-hex-decode-function-example
Advertisement
Something interesting
Tutorials
+20.6k Nginx + FastCGI + Go Setup.
+5.3k Golang : Generate Interleaved 2 inch by 5 inch barcode
+7.5k Golang : Dealing with struct's private part
+10.6k Golang : Get local time and equivalent time in different time zone
+8.8k Golang : Get final balance from bit coin address example
+5.2k Golang : Issue HTTP commands to server and port example
+6.7k Golang : Humanize and Titleize functions
+22.7k Golang : Set and Get HTTP request headers example
+4.1k Javascript : Empty an array example
+11.2k Google Maps URL parameters configuration
+18.1k Golang : Convert IPv4 address to decimal number(base 10) or integer
+11k Golang : Generate random elements without repetition or duplicate