Standard library / encoding/base64

encoding/base64.Encoding.DecodeString()

Decodes text using this alphabet; check the error even if bytes are returned. Expected stdout: 'Go\n'.

Formal Syntax & Structure

go syntaxgo
func (enc *Encoding) DecodeString(s string) ([]byte, error)

Parameters & Attributes

NameTypeDescription
sstringInput text or bytes.

Return Value

([]byte, error)

Resulting bytes (possibly partial for decoding) and error.

Working Example

Example Snippetgo
package main
import (  "encoding/base64"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() { p, e := base64.StdEncoding.DecodeString("R28="); must(e); fmt.Println(string(p)) }
Go Reference