This commit is contained in:
Artem Gavrilov
2024-04-18 11:48:37 +02:00
committed by GitHub
parent 46922a8540
commit 95c9020fa9
2 changed files with 7 additions and 7 deletions

View File

@@ -73,15 +73,15 @@ func checkUpdates(url string, timeout time.Duration, toolName, version string) (
if err != nil {
return "", err
}
advices := []Advice{}
err = json.Unmarshal(body, &advices)
var advice []Advice
err = json.Unmarshal(body, &advice)
if err != nil {
return "", err
}
for _, advice := range advices {
if advice.ToolName == PERCONA_TOOLKIT {
return advice.Advice, nil
for _, a := range advice {
if a.ToolName == PERCONA_TOOLKIT {
return a.Advice, nil
}
}

View File

@@ -16,7 +16,7 @@ func TestCheckUpdates(t *testing.T) {
body, _ := ioutil.ReadAll(r.Body)
m := strings.Split(string(body), ";")
advices := []Advice{
advice := []Advice{
{
Hash: m[0],
ToolName: m[1],
@@ -24,7 +24,7 @@ func TestCheckUpdates(t *testing.T) {
},
}
buf, _ := json.Marshal(advices)
buf, _ := json.Marshal(advice)
w.Header().Set("Content-Type", "application/json")
fmt.Fprint(w, string(buf))
}))