Skip to content

Instantly share code, notes, and snippets.

@isidroamv
Last active March 13, 2024 11:48
Show Gist options
  • Save isidroamv/1e1d1601926e62c1c86dce0d20428584 to your computer and use it in GitHub Desktop.
Save isidroamv/1e1d1601926e62c1c86dce0d20428584 to your computer and use it in GitHub Desktop.
Reading a txt gzip file with golang
func ReadGzFile(filename string) ([]byte, error) {
fi, err := os.Open(filename)
if err != nil {
return nil, err
}
defer fi.Close()
fz, err := gzip.NewReader(fi)
if err != nil {
return nil, err
}
defer fz.Close()
s, err := ioutil.ReadAll(fz)
if err != nil {
return nil, err
}
return s, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment