Golang encoding/hex.EncodedLen() function example

package encoding/hex

EncodedLen returns the length of an encoding of n source bytes.

Golang encoding/hex.EncodedLen() function usage example

 package main

 import (
 "encoding/hex"
 "fmt"
 )

 func main() {
 str := "abcd"

 fmt.Printf("Len size is : %v \n", len(str))

 fmt.Printf("EncodedLen(count number of bytes) size is : %v \n", hex.EncodedLen(len(str)))

 }

Output :

Len size is : 4

EncodedLen(count number of bytes) size is : 8

Reference :

http://golang.org/pkg/encoding/hex/#EncodedLen

Advertisement