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
+19.5k Golang : How to Set or Add Header http.ResponseWriter?
+7.9k Golang : Get today's weekday name and calculate target day distance example
+15.9k Golang : Update database with GORM example
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+8.2k Golang : Routes multiplexer routing example with regular expression control
+29.8k Golang : How to get HTTP request header information?
+5.1k Golang : Check if a word is countable or not
+11k Golang : Generate random elements without repetition or duplicate
+25.7k Golang : How to write CSV data to file
+10.9k Golang : How to transmit update file to client by HTTP request example
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator
+7.9k Golang : Ways to recover memory during run time.