aboutsummaryrefslogtreecommitdiff
path: root/internal/url.go
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-10-02 16:49:36 -0500
committerSlack Coder <slackcoder@server.ky>2024-10-02 17:01:48 -0500
commit2597c03d1555e00dec59830b7de75e7090208e05 (patch)
tree5642202b4621ea722ee85b322d79bbad17894026 /internal/url.go
parentb81d017b42cc814e603de2b49e4b78362ae73f2a (diff)
downloadmirror-2597c03d1555e00dec59830b7de75e7090208e05.tar.xz
config: Use TOML
TOML is simple for users, and it is used in notably projects like rustlang. It also provides comments!
Diffstat (limited to 'internal/url.go')
-rw-r--r--internal/url.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/internal/url.go b/internal/url.go
index 3a8d20a..d7a712d 100644
--- a/internal/url.go
+++ b/internal/url.go
@@ -2,10 +2,27 @@ package internal
import "net/url"
-func MustURL(arg string) *url.URL {
+type URL struct {
+ *url.URL
+}
+
+func (u *URL) MarshalText() ([]byte, error) {
+ return []byte(u.URL.String()), nil
+}
+
+func (u *URL) UnmarshalText(buf []byte) error {
+ var err error
+ u.URL, err = url.Parse(string(buf))
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func MustURL(arg string) *URL {
u, err := url.Parse(arg)
if err != nil {
panic(err)
}
- return u
+ return &URL{u}
}