mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-07 16:33:40 +00:00
40 lines
565 B
Go
40 lines
565 B
Go
package main
|
|
|
|
import (
|
|
"compress/gzip"
|
|
"io"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
|
|
/*
|
|
Uncompress a File
|
|
Uncompress means = never compressed
|
|
Decompress correct word.
|
|
*/
|
|
|
|
gzipFile, err := os.Open("test.txt.gz")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
gzipReader, err := gzip.NewReader(gzipFile)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer gzipReader.Close()
|
|
|
|
outfileWriter, err := os.Create("unzipped.txt")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
defer outfileWriter.Close()
|
|
|
|
_, err = io.Copy(outfileWriter, gzipReader)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|