更改项目结构

This commit is contained in:
2024-03-20 20:54:23 +08:00
committed by Nite07
parent 2bb9fb7510
commit 43f7a1ed4e
27 changed files with 210 additions and 212 deletions

25
util/fetch.go Normal file
View File

@@ -0,0 +1,25 @@
package util
import (
"io"
"net/http"
)
func Fetch(url string, maxRetryTimes int) (string, error) {
retryTime := 0
var err error
for retryTime < maxRetryTimes {
resp, err := http.Get(url)
if err != nil {
retryTime++
continue
}
data, err := io.ReadAll(resp.Body)
if err != nil {
retryTime++
continue
}
return string(data), err
}
return "", err
}