aboutsummaryrefslogtreecommitdiff
path: root/internal/rtree/remote.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-06-10 00:07:56 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-06-10 00:07:56 +0200
commitdaeb9127764fc9dd469294f755e277fdfca09a00 (patch)
treeec5cd2b83e5f097527eaea985790e7ac49fa95cb /internal/rtree/remote.go
parent6903a774ecbbd05596adda5e2b5e18d58dd3a8f9 (diff)
downloadgofu-daeb9127764fc9dd469294f755e277fdfca09a00.tar.gz
rtree: add support for multiple URLs per remote
This requires changing the index format, which I'm using as an opportunity to: - move from YAML to JSON (so I can maybe kill the YAML parser dependency at some point) - move the index file into standard XDG paths
Diffstat (limited to 'internal/rtree/remote.go')
-rw-r--r--internal/rtree/remote.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/rtree/remote.go b/internal/rtree/remote.go
index afcdf9b..8c355a8 100644
--- a/internal/rtree/remote.go
+++ b/internal/rtree/remote.go
@@ -4,6 +4,7 @@
package rtree
import (
+ "encoding/json"
"net/url"
"path/filepath"
"regexp"
@@ -86,16 +87,16 @@ func (u RemoteURL) CheckoutPath() (string, error) {
return filepath.Join(parsed.Hostname(), parsed.Path), nil
}
-// MarshalYAML implements the yaml.Marshaler interface.
-func (u RemoteURL) MarshalYAML() (any, error) {
+// MarshalJSON implements the json.Marshaler interface.
+func (u RemoteURL) MarshalJSON() ([]byte, error) {
//store URLs in the index in the canonical format
- return u.CanonicalURL(), nil
+ return json.Marshal(u.CanonicalURL())
}
-// UnmarshalYAML implements the yaml.Unmarshaler interface.
-func (u *RemoteURL) UnmarshalYAML(unmarshal func(any) error) error {
+// UnmarshalJSON implements the json.Unmarshaler interface.
+func (u *RemoteURL) UnmarshalJSON(buf []byte) error {
var s string
- err := unmarshal(&s)
+ err := json.Unmarshal(buf, &s)
if err == nil {
*u = ParseRemoteURL(s)
}