package main
import (
"bufio"
"compress/gzip"
"log"
"os"
)
func readGzipLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
gz, err := gzip.NewReader(file)
if err != nil {
log.Fatal(err)
}
defer file.Close()
defer gz.Close()
scanner := bufio.NewScanner(gz)
var lines []string
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}
Last active
February 12, 2023 00:20
-
-
Save misterunix/9244d88f3d88d58a3897e19b19c4fc31 to your computer and use it in GitHub Desktop.
Read a gzip file
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment