Documentation ¶
Overview ¶
Package zippity creates zip files, quickly.
Example ¶
package main import ( "fmt" "github.com/groundbreaker/zippity" ) func main() { pdf := zippity.ReadFile("test.pdf", "fine.pdf") zf := zippity.New() zip := zf.Add(pdf).Done() fmt.Printf("zip is %d bytes", len(zip)) }
Output: zip is 705454 bytes
Example (Chained) ¶
package main import ( "fmt" "github.com/groundbreaker/zippity" ) func main() { pdf := zippity.ReadFile("test.pdf", "fine.pdf") txt := &zippity.File{ Name: "test.txt", Body: []byte("Already have the bytes? Then, create a literal File."), } zf := zippity.New() zip := zf.Add(pdf).Add(txt).Done() fmt.Printf("zip is %d bytes", len(zip)) }
Output: zip is 705620 bytes
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Zipfile ¶
Zipfile encapsulates the data and behviour required to create zip file archives.
func (*Zipfile) Done ¶
Done returns the Zipfile as bytes. It must be called after you are done Adding Files to the Zipfile. You should only call Done() or Save(), but never both, or the second call will panic.
func (*Zipfile) Save ¶
Save the Zipfile to the given path. It must be called after you are done Adding Files to the Zipfile. You should only call Save() or Done(), but never both, or the second call will panic.
Example ¶
package main import ( "github.com/groundbreaker/zippity" ) func main() { pdf := zippity.ReadFile("test.pdf", "fine.pdf") txt := &zippity.File{ Name: "test.txt", Body: []byte("Already have the bytes? Then, create a literal File."), } zf := zippity.New() zf.Add(pdf).Add(txt).Save("test.zip") }
Output:
Click to show internal directories.
Click to hide internal directories.