Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 1.22 KB

README.md

File metadata and controls

43 lines (36 loc) · 1.22 KB

ZipStream

Build Status GoDoc Go Report Card Codacy Badge

Enables zip file reading from a io.Reader stream on the fly.

Example

package main

import (
	"github.com/gofunky/zipstream"
	"bytes"
	"io"
	"log"
	"io/ioutil"
	)

func main() {
	// Read the first compressed file from a zip file.
	var zipFile bytes.Buffer
    zr := zipstream.NewReader(&zipFile)
	meta, err := zr.Next()
	if err != nil {
		if err != io.EOF {
			panic(err)
		}
	}
	log.Printf("file name: %s", meta.Name)
	compressedFile, err := ioutil.ReadAll(zr)
	if err != nil {
		panic(err)
	}
	log.Printf("file content: %s", string(compressedFile[:]))
}

History

golang/go#10568