Standard library / encoding/hex
encoding/hex.EncodeToString()
Converts bytes to lowercase hexadecimal text; each byte occupies two digits. Expected stdout: '00ff\n'.
Formal Syntax & Structure
go syntaxgo
func EncodeToString(src []byte) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| src | []byte | Source bytes to encode or decode. |
Return Value
string
Text representation.
Working Example
Example Snippetgo
package main
import ( "encoding/hex" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { fmt.Println(hex.EncodeToString([]byte{0, 255})) }