Skip to content

Instantly share code, notes, and snippets.

@piEsposito
Created February 14, 2020 14:01
Show Gist options
  • Save piEsposito/4bea3770caa60060414784ad4a3583ef to your computer and use it in GitHub Desktop.
Save piEsposito/4bea3770caa60060414784ad4a3583ef to your computer and use it in GitHub Desktop.
package query_handler
import (
"compress/gzip"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func ConvertGzipToString(resp *http.Response) string {
/*
As our return from the request is compressed in gzip format,
We return it as a string to be written in a file
*/
reader, _ := gzip.NewReader(resp.Body)
result, _ := ioutil.ReadAll(reader)
return string(result)
}
func SaveJsonString(content string, path string) {
/*
With this function we save our crawled Json to string
*/
f, _ := os.Create(path)
fmt.Fprintln(f, content)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment