Golang encoding/ascii85.NewEncoder function example

package encoding/ascii85

NewEncoder returns a new ascii85 stream encoder. Data written to the returned writer will be encoded and then written to w. Ascii85 encodings operate in 32-bit blocks; when finished writing, the caller must Close the returned encoder to flush any trailing partial block.

Golang encoding/ascii85.NewEncoder function usage example

 package main

 import (
 "encoding/ascii85"
 "fmt"
 "bytes"
 )

 func main() {

  var bytesbuf bytes.Buffer

  encoderstream := ascii85.NewEncoder(&bytesbuf)
  encoderstream.Write([]byte("abc123"))
  encoderstream.Close()
 }

Reference :

http://golang.org/pkg/encoding/ascii85/#NewEncoder

Advertisement