Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
6f88288a
Commit
6f88288a
authored
Apr 28, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xml: fix reflect error
Fixes #1749. R=bradfitz CC=golang-dev
https://golang.org/cl/4431075
parent
df2c5d54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
44 deletions
+46
-44
src/pkg/xml/read.go
src/pkg/xml/read.go
+3
-6
src/pkg/xml/xml_test.go
src/pkg/xml/xml_test.go
+43
-38
No files found.
src/pkg/xml/read.go
View file @
6f88288a
...
...
@@ -220,13 +220,10 @@ func (p *Parser) unmarshal(val reflect.Value, start *StartElement) os.Error {
}
if
pv
:=
val
;
pv
.
Kind
()
==
reflect
.
Ptr
{
if
pv
.
Pointer
()
==
0
{
zv
:=
reflect
.
Zero
(
pv
.
Type
()
.
Elem
())
pv
.
Set
(
zv
.
Addr
())
val
=
zv
}
else
{
val
=
pv
.
Elem
()
if
pv
.
IsNil
()
{
pv
.
Set
(
reflect
.
New
(
pv
.
Type
()
.
Elem
()))
}
val
=
pv
.
Elem
()
}
var
(
...
...
src/pkg/xml/xml_test.go
View file @
6f88288a
...
...
@@ -329,46 +329,50 @@ func TestSyntax(t *testing.T) {
}
type
allScalars
struct
{
True1
bool
True2
bool
False1
bool
False2
bool
Int
int
Int8
int8
Int16
int16
Int32
int32
Int64
int64
Uint
int
Uint8
uint8
Uint16
uint16
Uint32
uint32
Uint64
uint64
Uintptr
uintptr
Float32
float32
Float64
float64
String
string
True1
bool
True2
bool
False1
bool
False2
bool
Int
int
Int8
int8
Int16
int16
Int32
int32
Int64
int64
Uint
int
Uint8
uint8
Uint16
uint16
Uint32
uint32
Uint64
uint64
Uintptr
uintptr
Float32
float32
Float64
float64
String
string
PtrString
*
string
}
var
all
=
allScalars
{
True1
:
true
,
True2
:
true
,
False1
:
false
,
False2
:
false
,
Int
:
1
,
Int8
:
-
2
,
Int16
:
3
,
Int32
:
-
4
,
Int64
:
5
,
Uint
:
6
,
Uint8
:
7
,
Uint16
:
8
,
Uint32
:
9
,
Uint64
:
10
,
Uintptr
:
11
,
Float32
:
13.0
,
Float64
:
14.0
,
String
:
"15"
,
}
True1
:
true
,
True2
:
true
,
False1
:
false
,
False2
:
false
,
Int
:
1
,
Int8
:
-
2
,
Int16
:
3
,
Int32
:
-
4
,
Int64
:
5
,
Uint
:
6
,
Uint8
:
7
,
Uint16
:
8
,
Uint32
:
9
,
Uint64
:
10
,
Uintptr
:
11
,
Float32
:
13.0
,
Float64
:
14.0
,
String
:
"15"
,
PtrString
:
&
sixteen
,
}
var
sixteen
=
"16"
const
testScalarsInput
=
`<allscalars>
<true1>true</true1>
...
...
@@ -390,6 +394,7 @@ const testScalarsInput = `<allscalars>
<float32>13.0</float32>
<float64>14.0</float64>
<string>15</string>
<ptrstring>16</ptrstring>
</allscalars>`
func
TestAllScalars
(
t
*
testing
.
T
)
{
...
...
@@ -401,7 +406,7 @@ func TestAllScalars(t *testing.T) {
t
.
Fatal
(
err
)
}
if
!
reflect
.
DeepEqual
(
a
,
all
)
{
t
.
Errorf
(
"
expected %+v got %+v"
,
all
,
a
)
t
.
Errorf
(
"
have %+v want %+v"
,
a
,
all
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment