You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
438 B

package utils
import (
"fmt"
"io"
"net/http"
)
func HTTPGet(url string) []byte {
method := "GET"
client := &http.Client{}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return nil
}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return nil
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return nil
}
return body
}