josa42 / go-zip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

zip

Build Status

🚧 Work in progress

Examples

See also: examples/main.go.

Compress

a, _ := zip.CreateArchive("test.zip")
defer a.Close()

a.Add(".", "test")

Optionally function function can be provided, to ignore specific files or directories.

a, _ := zip.CreateArchive("test.zip")
defer a.Close()

a.Add(".", "test", func(path string, sourcePath string) bool {

  // The file / directory will be ignored if `false` is returned
  if path == ".git" {
    fmt.Println("> Ignore:", path)
    return false
  }

  fmt.Println("> Add:   ", path)
  return true
})

List archive content

	a, _ := zip.OpenArchive("test.zip")
	defer a.Close()

	filePaths, _ := a.List()
	for _, f := range filePaths {
		fmt.Println(f)
	}

Todo

  • Extract archive

License

MIT © Josa Gesell

About

License:MIT License


Languages

Language:Go 100.0%