Run gofmt and fix the Unmarshal test.
This commit is contained in:
parent
6da9091d5a
commit
032fe9d27c
22
document.go
22
document.go
|
@ -43,22 +43,22 @@ type CharsetFunc func(charset string, input io.Reader) (io.Reader, error)
|
||||||
|
|
||||||
// represents a single XML document.
|
// represents a single XML document.
|
||||||
type Document struct {
|
type Document struct {
|
||||||
Version string // XML version
|
Version string // XML version
|
||||||
Encoding string // Encoding found in document. If absent, assumes UTF-8.
|
Encoding string // Encoding found in document. If absent, assumes UTF-8.
|
||||||
StandAlone string // Value of XML doctype's 'standalone' attribute.
|
StandAlone string // Value of XML doctype's 'standalone' attribute.
|
||||||
Entity map[string]string // Mapping of custom entity conversions.
|
Entity map[string]string // Mapping of custom entity conversions.
|
||||||
Root *Node // The document's root node.
|
Root *Node // The document's root node.
|
||||||
SaveDocType bool // Whether not to include the XML doctype in saves.
|
SaveDocType bool // Whether not to include the XML doctype in saves.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new, empty XML document instance.
|
// Create a new, empty XML document instance.
|
||||||
func New() *Document {
|
func New() *Document {
|
||||||
return &Document{
|
return &Document{
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Encoding: "utf-8",
|
Encoding: "utf-8",
|
||||||
StandAlone: "yes",
|
StandAlone: "yes",
|
||||||
SaveDocType: true,
|
SaveDocType: true,
|
||||||
Entity: make(map[string]string),
|
Entity: make(map[string]string),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
xmlx_test.go
14
xmlx_test.go
|
@ -85,12 +85,12 @@ func TestNodeSearch(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Image struct {
|
type Image struct {
|
||||||
Title string
|
Title string `xml:"title"`
|
||||||
Url string
|
Url string `xml:"url"`
|
||||||
Link string
|
Link string `xml:"link"`
|
||||||
Width string
|
Description string `xml:"description"`
|
||||||
Height string
|
Width int `xml:"width"`
|
||||||
Description string
|
Height int `xml:"height"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshal(t *testing.T) {
|
func TestUnmarshal(t *testing.T) {
|
||||||
|
@ -108,7 +108,7 @@ func TestUnmarshal(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
img := Image{}
|
var img Image
|
||||||
if err = node.Unmarshal(&img); err != nil {
|
if err = node.Unmarshal(&img); err != nil {
|
||||||
t.Errorf("Unmarshal(): %s", err)
|
t.Errorf("Unmarshal(): %s", err)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue