aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-03-06 07:26:52 +1300
committerArslaan Pathan <[email protected]>2026-03-06 07:26:52 +1300
commitbc8d25088706ac808eb4c4e337ea02b57413c234 (patch)
tree900686ad5b86da5a887f99a7a7ab022fb61b5186 /internal
parentbd6f6fbe80ef419fdf38c4154add3c4d7a452da0 (diff)
downloadkiiro-bc8d25088706ac808eb4c4e337ea02b57413c234.tar.xz
kiiro-bc8d25088706ac808eb4c4e337ea02b57413c234.zip
say unfinished
Diffstat (limited to 'internal')
-rw-r--r--internal/manifest/manifest.go13
-rw-r--r--internal/sources/sources.go17
2 files changed, 23 insertions, 7 deletions
diff --git a/internal/manifest/manifest.go b/internal/manifest/manifest.go
index aea7fbe..79642cc 100644
--- a/internal/manifest/manifest.go
+++ b/internal/manifest/manifest.go
@@ -3,6 +3,15 @@
package manifest
+import (
+ "fmt"
+ "encoding/json"
+ "net/http"
+ "log"
+ "io"
+ "errors"
+)
+
type KiiroToml struct {
Name string `toml:"pkgname"`
Version string `toml:"version"`
@@ -12,3 +21,7 @@ type KiiroToml struct {
Depends []string `toml:"deps"`
}
+func FetchKiiroToml(url string) (*KiiroToml, error) {
+ fmt.Println("Fetching kiiro.toml...")
+ return nil, errors.New("not implemented")
+}
diff --git a/internal/sources/sources.go b/internal/sources/sources.go
index 6a99cb2..434e734 100644
--- a/internal/sources/sources.go
+++ b/internal/sources/sources.go
@@ -7,7 +7,6 @@ import (
"fmt"
"encoding/json"
"net/http"
- "log"
"io"
)
@@ -22,7 +21,6 @@ func FetchPackageListing(url string) (*PackageListing, error) {
res, err := http.Get(url)
if err != nil {
- log.Fatal(err)
return nil, err
}
@@ -30,20 +28,25 @@ func FetchPackageListing(url string) (*PackageListing, error) {
res.Body.Close()
if res.StatusCode > 299 {
- log.Fatalf("Response failed with status code: %d", res.StatusCode)
return nil, err
}
if err != nil {
- log.Fatal(err)
return nil, err
}
- var packageListing PackageListing
- err = json.Unmarshal(body, &packageListing)
+ packageListing, err := ParsePackageListing(body)
if err != nil {
- log.Fatal(err)
return nil, err
}
fmt.Println("Fetched package listing!")
+ return packageListing, nil
+}
+
+func ParsePackageListing(pkgListingJSON []byte) (*PackageListing, error) {
+ var packageListing PackageListing
+ err := json.Unmarshal(pkgListingJSON, &packageListing)
+ if err != nil {
+ return nil, err
+ }
return &packageListing, nil
}