Standard library / encoding/base64

encoding/base64.Encoding.EncodeToString()

Encodes bytes as text. Base64 is reversible and provides no secrecy. Expected stdout: 'R28=\n'.

Formal Syntax & Structure

go syntaxgo
func (enc *Encoding) EncodeToString(src []byte) string

Parameters & Attributes

NameTypeDescription
src[]byteSource bytes to encode or decode.

Return Value

string

Text representation.

Working Example

Example Snippetgo
package main
import (  "encoding/base64"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { fmt.Println(base64.StdEncoding.EncodeToString([]byte("Go"))) }
Go Reference