Standard library / encoding/ascii85

encoding/ascii85.NewEncoder()

Wrap a writer with streaming ASCII85 encoding. Close the wrapper to emit a trailing partial group and check the close error. Expected stdout: '7rJ\n'.

Formal Syntax & Structure

go syntaxgo
func NewEncoder(w io.Writer) io.WriteCloser

Parameters & Attributes

NameTypeDescription
wio.WriterWriter receiving encoded data.

Return Value

io.WriteCloser

Encoding writer; close it to flush remaining input.

Working Example

Example Snippetgo
package main
import (  "bytes"  "encoding/ascii85"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  var buf bytes.Buffer  w := ascii85.NewEncoder(&buf)  _, err := w.Write([]byte("G"))  must(err)  _, err = w.Write([]byte("o"))  must(err)  must(w.Close())  fmt.Println(buf.String())}
Go Reference