Standard library / encoding/hex

encoding/hex.DecodedLen()

Returns the maximum decoded length for n hexadecimal digits; odd lengths still produce errors during decoding. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func DecodedLen(x int) int

Parameters & Attributes

NameTypeDescription
xintInteger value to encode, or length for DecodedLen.

Return Value

int

Number of bytes or required size, as described above.

Working Example

Example Snippetgo
package main
import (  "encoding/hex"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { fmt.Println(hex.DecodedLen(5)) }
Go Reference