mirror of https://github.com/golang/go.git
parent
9177e12ccc
commit
f188b91978
|
|
@ -2,3 +2,4 @@ pkg encoding, type BinaryAppender interface { AppendBinary } #62384
|
|||
pkg encoding, type BinaryAppender interface, AppendBinary([]uint8) ([]uint8, error) #62384
|
||||
pkg encoding, type TextAppender interface { AppendText } #62384
|
||||
pkg encoding, type TextAppender interface, AppendText([]uint8) ([]uint8, error) #62384
|
||||
pkg net/url, method (*URL) AppendBinary([]uint8) ([]uint8, error) #62384
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
[URL] now also implements the [encoding.BinaryAppender] interface.
|
||||
|
|
@ -1219,7 +1219,11 @@ func splitHostPort(hostPort string) (host, port string) {
|
|||
// Would like to implement MarshalText/UnmarshalText but that will change the JSON representation of URLs.
|
||||
|
||||
func (u *URL) MarshalBinary() (text []byte, err error) {
|
||||
return []byte(u.String()), nil
|
||||
return u.AppendBinary(nil)
|
||||
}
|
||||
|
||||
func (u *URL) AppendBinary(b []byte) ([]byte, error) {
|
||||
return append(b, u.String()...), nil
|
||||
}
|
||||
|
||||
func (u *URL) UnmarshalBinary(text []byte) error {
|
||||
|
|
|
|||
|
|
@ -1866,6 +1866,7 @@ func TestURLHostnameAndPort(t *testing.T) {
|
|||
|
||||
var _ encodingPkg.BinaryMarshaler = (*URL)(nil)
|
||||
var _ encodingPkg.BinaryUnmarshaler = (*URL)(nil)
|
||||
var _ encodingPkg.BinaryAppender = (*URL)(nil)
|
||||
|
||||
func TestJSON(t *testing.T) {
|
||||
u, err := Parse("https://www.google.com/x?y=z")
|
||||
|
|
|
|||
Loading…
Reference in New Issue