Last active
February 13, 2019 23:39
-
-
Save denniskupec/e087817d2533347e05d6fbbcef1819b4 to your computer and use it in GitHub Desktop.
fcat, zcat for zlib packs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"compress/gzip" | |
"io" | |
"log" | |
"os" | |
) | |
func main() { | |
var ( | |
f *os.File | |
err error | |
) | |
if len(os.Args) < 2 { | |
f = os.Stdin | |
} else { | |
f, err = os.Open(os.Args[1]) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer f.Close() | |
} | |
zr, err := gzip.NewReader(f) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer zr.Close() | |
io.Copy(os.Stdout, zr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment