Created
July 22, 2015 18:35
-
-
Save vbatts/544f62fb433093e26a3a to your computer and use it in GitHub Desktop.
This file contains 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" | |
"os" | |
) | |
// usage `cat foo.gz | ./gogunzip > foo` | |
func main() { | |
gr, err := gzip.NewReader(os.Stdin) | |
if err != nil { | |
os.Stderr.WriteString(err.Error()) | |
os.Exit(1) | |
} | |
defer gr.Close() | |
if _, err := io.Copy(os.Stdout, gr); err != nil { | |
os.Stderr.WriteString(err.Error()) | |
os.Exit(1) | |
} | |
} |
This file contains 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" | |
"os" | |
) | |
// usage `cat foo | ./gogzip > foo.gz` | |
func main() { | |
gw := gzip.NewWriter(os.Stdout) | |
defer gw.Close() | |
if _, err := io.Copy(gw, os.Stdin); err != nil { | |
os.Stderr.WriteString(err.Error()) | |
os.Exit(1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment