mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-06 10:20:26 +02:00
move shared code to pkg.
This commit is contained in:
parent
94c17e9a42
commit
8593d2d0fd
93 changed files with 132 additions and 133 deletions
22
pkg/utils/request.go
Normal file
22
pkg/utils/request.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue