gozip

package module
v0.0.0-...-b270562 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

gozip

gozip is a simple edit zip file library add file to zip file, edit sub file in zip ... everything is easy.

Example:
func Test_gozip(t *testing.T){
	gz := NewGozip()
	err := gz.Open("test.zip")
	if err != nil{
		log.Println(err)
		return
	}
	for i := 140;i < 150 ;i++{
		fileName := fmt.Sprintf("t-%d.txt",i)
		text := fmt.Sprintf("[%d]--askfjalsjklkjljasdfasdfasdfasdfasdf",i)
        //Does not exist, will be created, there is an overwrite
		_,err := gz.WriteFile(fileName,[]byte(text))
		if err != nil{
			log.Println("@@@",i,err)
			return
		}
		gz.Flush()
		log.Println("End: ",i)
		time.Sleep(time.Second * 2)
	}
	gz.RemoveFile("t-118.txt")
	err = gz.Close()
	if err != nil{
		log.Println(err)
		return
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gozip

type Gozip struct {
	ZipFileName string
	// contains filtered or unexported fields
}

func NewGozip

func NewGozip() *Gozip

func (*Gozip) Close

func (gz *Gozip) Close() (err error)

func (*Gozip) Flush

func (gz *Gozip) Flush() error

func (*Gozip) Open

func (gz *Gozip) Open(fileName string) (err error)

func (*Gozip) RemoveFile

func (gz *Gozip) RemoveFile(fileName string)

func (*Gozip) WriteFile

func (gz *Gozip) WriteFile(fileName string, data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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