mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/xml: remove Marshaler support
Marshaler has a number of open areas that need further thought (e.g. it doesn't handle attributes, it's supposed to handle tag names internally but has no information to do so, etc). We're removing it now and will bring it back with an interface that covers these aspects, after Go 1. Related to issue 2771, but doesn't fix it. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5574057
This commit is contained in:
parent
ddd67f2ecd
commit
66599c4070
2 changed files with 0 additions and 33 deletions
|
|
@ -21,16 +21,8 @@ const (
|
|||
Header = `<?xml version="1.0" encoding="UTF-8"?>` + "\n"
|
||||
)
|
||||
|
||||
// A Marshaler can produce well-formatted XML representing its internal state.
|
||||
type Marshaler interface {
|
||||
MarshalXML() ([]byte, error)
|
||||
}
|
||||
|
||||
// Marshal returns the XML encoding of v.
|
||||
//
|
||||
// If v implements Marshaler, then Marshal calls its MarshalXML method.
|
||||
// Otherwise, Marshal uses the following procedure to create the XML.
|
||||
//
|
||||
// Marshal handles an array or slice by marshalling each of the elements.
|
||||
// Marshal handles a pointer by marshalling the value it points at or, if the
|
||||
// pointer is nil, by writing nothing. Marshal handles an interface value by
|
||||
|
|
@ -128,18 +120,6 @@ func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo) error {
|
|||
kind := val.Kind()
|
||||
typ := val.Type()
|
||||
|
||||
// Try Marshaler
|
||||
if typ.NumMethod() > 0 {
|
||||
if marshaler, ok := val.Interface().(Marshaler); ok {
|
||||
bytes, err := marshaler.MarshalXML()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.Write(bytes)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Drill into pointers/interfaces
|
||||
if kind == reflect.Ptr || kind == reflect.Interface {
|
||||
if val.IsNil() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue