Golang compress/zlib.NewReader() function example
package compress/zlib
Golang compress/zlib.NewReader() function usage example.
package main
import (
"compress/zlib"
"fmt"
"io"
"os"
)
func main() {
inputFile, err := os.Open("file.txt.zlib")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer inputFile.Close()
outputFile, err := os.Create("file.txt")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer outputFile.Close()
reader, _ := zlib.NewReader(inputFile) //<--- here!
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer reader.Close()
io.Copy(outputFile, reader)
}
References :
https://golang.org/pkg/compress/zlib/#NewReader
https://www.socketloop.com/tutorials/golang-decompress-zlib-file-example
Advertisement
Something interesting
Tutorials
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+6.4k Golang : Handling image beyond OpenCV video capture boundary
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+8.3k Golang : Check if integer is power of four example
+9.5k Golang : Get all countries currencies code in JSON format
+6.6k Golang : Totalize or add-up an array or slice example
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+7.9k Javascript : How to check a browser's Do Not Track status?
+6.7k Golang : Derive cryptographic key from passwords with Argon2
+20.6k Golang : Secure(TLS) connection between server and client