It's a simple type that implements the Marshaler and Unmarshaler interfaces for a URL transforming it to an string.
$> go get github.com/xescugc/url-marshaler
import (
"encoding/json"
"fmt"
"net/url"
marshaler "github.com/xescugc/url-marshaler"
)
type User struct {
Name string `json:"name"`
URL marshaler.URL `json:"url"`
}
func main() {
u, _ := url.Parse("http://example.com")
usr := User{
Name: "Pepito",
URL: marshaler.URL{
URL: u,
},
}
b, _ := json.Marshal(usr)
fmt.Println(string(b))
// { "name": "Pepito", "url": "http://example.com" }
}