You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to create a simple example based on the documentation
godoc encoding/xml Unmarshal
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
osx
Which revision are you using? (hg identify)
1107a7d3cb07 weekly/weekly.2012-01-27
I tried this test case and it fails with the error EOF
:-
package main
import (
"testing"
"encoding/xml"
)
type Email struct {
Where string `xml:",attr"`
Addr string
}
type Result struct {
Email []Email
}
func Test_Update_2(t *testing.T) {
result := new(Result)
body := "<result> <email where='home'> <addr>gre@example.com</addr> </email>"
err := xml.Unmarshal([]byte(body), &result)
if err != nil {
t.Error("xml.UnMarshal:", err)
}
t.Log("result:", result)
}
The text was updated successfully, but these errors were encountered:
the EOF is caused by the lack of result but the unmarshal still seems broken. The logs
indicates unmarshal didnt do anything
func Test_Update_2(t *testing.T) {
result := new(Result)
body := "<result> <email where='home'> <addr>gre@example.com</addr> </email></result>"
err := xml.Unmarshal([]byte(body), &result)
if err != nil {
t.Error("xml.UnMarshal:", err)
}
t.Error("result:", result)
}
--- FAIL: main.Test_Update_2 (0.00 seconds)
y.go:981: result: &{[]}
FAIL
by abdul.h.chaudhry:
The text was updated successfully, but these errors were encountered: