move shared code to pkg.

This commit is contained in:
Miroslav Šedivý 2022-03-20 11:43:00 +01:00
parent 94c17e9a42
commit 8593d2d0fd
93 changed files with 132 additions and 133 deletions

22
pkg/utils/request.go Normal file
View file

@ -0,0 +1,22 @@
package utils
import (
"bytes"
"io"
"net/http"
)
func HttpRequestGET(url string) (string, error) {
rsp, err := http.Get(url)
if err != nil {
return "", err
}
defer rsp.Body.Close()
buf, err := io.ReadAll(rsp.Body)
if err != nil {
return "", err
}
return string(bytes.TrimSpace(buf)), nil
}