♻️ Migrate from gorm/sqlite to boltdb

This commit is contained in:
2024-04-24 12:51:37 +08:00
parent 3d3b4e0bea
commit 566965bb6a
12 changed files with 183 additions and 264 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"sub2clash/config"
@ -57,11 +58,11 @@ func FetchSubscriptionFromAPI(url string) ([]byte, error) {
if err != nil {
return nil, err
}
defer func(Body io.ReadCloser) {
if Body != nil {
_ = Body.Close()
defer func(resp *http.Response) {
if resp != nil && resp.Body != nil {
_ = resp.Body.Close()
}
}(resp.Body)
}(resp)
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)