zip

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 7 Imported by: 1

README

zip

Static Badge Build Go Reference codecov Release Go Report Card codebeat badge License

Package zip process a compressed file read, write and clone it

Install

$> go get github.com/gofast-pkg/zip@latest

Usage

import github.com/gofast-pkg/zip

func main() {
  file, err := os.Open(testReadCloserZipFile)
  if err != nil {
    panic(err)
  }
  defer file.Close()

  r, err := zip.NewReader(file)
  if err != nil {
    log.Fatal(err)
  }

  // Iterate through the files in the archive,
  for i := 0; i < r.NFiles(); i++ {
    var content []byte
    if content, err = r.ContentFile(i); err != nil {
      panic(err)
    }
    // do something
  }
}

Check the go documentation for more details.

Contributing

 ❕  Use issues for everything

Read more informations with the CONTRIBUTING_GUIDE

For all changes, please update the CHANGELOG.txt file by replacing the existant content.

Thank you  🙏  👍 

Made with contrib.rocks.

Licence

MIT

Documentation

Overview

Package zip process a compressed file / body

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIndex = errors.New("file index reference is invalid")
	ErrInvalidInput = errors.New("could not create a new reader with nil input")
)

error list

Functions

This section is empty.

Types

type Reader

type Reader interface {
	Create(filepath string) error
	NFiles() int
	ContentFile(index int) ([]byte, error)
	InfoFile(index int) (fs.FileInfo, error)
	WriteFile(index int, filepath string) error
}

Reader is the interface that wraps the basic methods to process a compressed file / body

func NewReader

func NewReader(input io.ReadCloser) (Reader, error)

NewReader returns a Reader interface It receives a io.ReadCloser interface from http request or file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL