Last active
March 13, 2024 11:48
-
-
Save isidroamv/1e1d1601926e62c1c86dce0d20428584 to your computer and use it in GitHub Desktop.
Reading a txt gzip file with golang
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
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