Files
BedrockFetch/main.go
Matheus Sampaio Queiroga cc50a88525
All checks were successful
Find and Upload Minecraft Server versions / build (push) Successful in 1m28s
Fix fetch
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2024-04-29 21:22:37 -03:00

51 lines
892 B
Go

package main
import (
"encoding/json"
"os"
"path/filepath"
"sirherobrine23.org/minecraft-server/bedrockfetch/internal"
)
func main() {
localReleases := internal.Versions{}
VersionsPathFile, _ := filepath.Abs("./versions.json")
file, err := os.Open(VersionsPathFile)
if err != nil {
panic(err)
}
defer file.Close()
if err = json.NewDecoder(file).Decode(&localReleases); err != nil {
panic(err)
}
file.Close()
// Find urls
links, err := internal.FindUrls()
if err != nil {
panic(err)
}
// Add extra urls to links
for _, arg := range os.Args {
if arg[0:8] == "https://" {
links = append(links, arg)
}
}
// Insert to local release
if err = localReleases.Parse(links); err != nil {
panic(err)
}
file, err = os.Create(VersionsPathFile)
if err != nil {
panic(err)
}
et := json.NewEncoder(file)
et.SetIndent("", " ")
et.Encode(&localReleases)
}