How to read and get the complete text line from compressed file using golang

Here is the answer I solved above question.

cmd := exec.Command(`zgrep`, `WARNING\|ERROR`, filename)
stdout, err := cmd.StdoutPipe()

if err != nil {
    log.Fatal(err)
}

if err := cmd.Start(); err != nil {
    log.Fatal(err)
}

data, err := ioutil.ReadAll(stdout)

if err != nil {
    log.Fatal(err)
}

if err := cmd.Wait(); err != nil {
    
        log.Fatalf("cmd.Wait: %v", err)
    
}
lines := strings.Split(string(data), "\n")
for _, line := range lines {
    fmt.Println(line)
    
}