implement sonic for json + remove some TODOs from readme + fix go version requirement (#5)

This commit is contained in:
dogghi no 2025-04-17 14:16:30 +02:00 committed by GitHub
parent 4a15dd0761
commit e35bd2fe57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 70 additions and 47 deletions

View file

@ -1,15 +1,15 @@
package tiktok
import (
"encoding/json"
"fmt"
"io"
"net/http"
"regexp"
"govd/enums"
"govd/models"
"govd/util"
"github.com/bytedance/sonic"
)
const (
@ -166,13 +166,10 @@ func GetVideoAPI(awemeID string) (*AwemeDetails, error) {
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
var data *Response
err = json.Unmarshal(body, &data)
decoder := sonic.ConfigFastest.NewDecoder(resp.Body)
err = decoder.Decode(&data)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
}