diff options
Diffstat (limited to 'internal/url.go')
-rw-r--r-- | internal/url.go | 21 |
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} } |