Skip to content

Instantly share code, notes, and snippets.

@aaronlehmann
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronlehmann/2397d1184cdfa1ed12dd to your computer and use it in GitHub Desktop.
Save aaronlehmann/2397d1184cdfa1ed12dd to your computer and use it in GitHub Desktop.
Inconsistent compressed output between tarsum and direct gzip Writer
package main
import (
"compress/gzip"
"io"
"os"
"github.com/docker/docker/pkg/tarsum"
)
func main() {
gzippedFile, err := os.Create("normal.gz")
if err != nil {
panic(err.Error())
}
tarsumFile, err := os.Create("tarsum.gz")
if err != nil {
panic(err.Error())
}
gzipWriter := gzip.NewWriter(gzippedFile)
if err != nil {
panic(err.Error())
}
tarsumLayer, err := tarsum.NewTarSum(io.TeeReader(os.Stdin, gzipWriter), false, tarsum.Version0)
if err != nil {
panic(err.Error())
}
_, err = io.Copy(tarsumFile, tarsumLayer)
if err != nil {
panic(err.Error())
}
gzipWriter.Close()
gzippedFile.Close()
tarsumFile.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment