SHARE
TWEET

Untitled

a guest Oct 21st, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. func main() {
  4.  
  5. }
  6.  
  7. var writer io.Writer
  8. gzipWriter := gzip.NewWriter(writer)
  9.  
  10. var files = []struct {
  11. name    string
  12. comment string
  13. modTime time.Time
  14. data    string
  15. }{
  16. {"file-1.txt", "file-header-1", time.Now(), "Hello Gophers - 1"},
  17. {"file-2.txt", "file-header-2", time.Now(), "Hello Gophers - 2"},
  18. }
  19.  
  20. for _, file := range files {
  21. gzipWriter.Name = file.name
  22. gzipWriter.Comment = file.comment
  23. gzipWriter.ModTime = file.modTime
  24.  
  25. if _, err := gzipWriter.Write([]byte(file.data)); err != nil {
  26. log.Fatal(err)
  27. }
  28.  
  29. if err := gzipWriter.Close(); err != nil {
  30. log.Fatal(err)
  31. }
  32.  
  33. gzipWriter.Reset(writer)
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top