I have this simple code:
import (
"log"
"github.com/gorilla/http"
"bytes"
)
func main() {
url := "https://www.telegram.org"
log.Println("url: " + url)
var b bytes.Buffer
http.Get(&b, url)
log.Println("Get done")
}
and it freezes on the line making the GET request. It seems that it enters an infinite loop of 302 responses which redirects to the same url ("https://www.telegram.org"). Am I doing or assuming something wrong?
Thanks and regards.
Apparently that library doesn't support https (lol)
https://github.com/gorilla/http/issues/8
So just use the stdlib http module:
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
res, err := http.Get("https://www.telegram.org")
if err != nil {
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return
}
fmt.Printf("%s", body)
}