fixed formatting
This commit is contained in:
parent
3b89a26265
commit
0a6b37ccab
@ -2,10 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
@ -14,9 +14,9 @@ type App struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Modpack struct {
|
type Modpack struct {
|
||||||
Name string
|
Name string
|
||||||
Nd string
|
Nd string
|
||||||
Last_updated string
|
Last_updated string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApp creates a new App application struct
|
// NewApp creates a new App application struct
|
||||||
@ -36,23 +36,23 @@ func (a *App) Greet(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetModpacks() []string {
|
func (a *App) GetModpacks() []string {
|
||||||
res, err := http.Get("https://gitea.piwalker.net/fclauncher/modpacks.json")
|
res, err := http.Get("https://gitea.piwalker.net/fclauncher/modpacks.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
body , err := io.ReadAll(res.Body)
|
body, err := io.ReadAll(res.Body)
|
||||||
var modpacks []Modpack
|
var modpacks []Modpack
|
||||||
err = json.Unmarshal([]byte(body), &modpacks)
|
err = json.Unmarshal([]byte(body), &modpacks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var names []string
|
var names []string
|
||||||
for _, pack := range modpacks {
|
for _, pack := range modpacks {
|
||||||
names = append(names, pack.Name)
|
names = append(names, pack.Name)
|
||||||
}
|
}
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CheckPrerequisites() {
|
func (a *App) CheckPrerequisites() {
|
||||||
|
Loading…
Reference in New Issue
Block a user