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
13bb28a4
Commit
13bb28a4
authored
Apr 26, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template: fix handling of pointer inside interface
R=r CC=golang-dev
https://golang.org/cl/982043
parent
6f33f34b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
src/pkg/template/template.go
src/pkg/template/template.go
+1
-1
src/pkg/template/template_test.go
src/pkg/template/template_test.go
+7
-0
No files found.
src/pkg/template/template.go
View file @
13bb28a4
...
@@ -596,7 +596,7 @@ func (st *state) findVar(s string) reflect.Value {
...
@@ -596,7 +596,7 @@ func (st *state) findVar(s string) reflect.Value {
return
nil
return
nil
}
}
if
intf
,
ok
:=
data
.
(
*
reflect
.
InterfaceValue
);
ok
{
if
intf
,
ok
:=
data
.
(
*
reflect
.
InterfaceValue
);
ok
{
data
=
intf
.
Elem
(
)
data
=
reflect
.
Indirect
(
intf
.
Elem
()
)
}
}
switch
typ
:=
data
.
Type
()
.
(
type
)
{
switch
typ
:=
data
.
Type
()
.
(
type
)
{
...
...
src/pkg/template/template_test.go
View file @
13bb28a4
...
@@ -48,6 +48,7 @@ type S struct {
...
@@ -48,6 +48,7 @@ type S struct {
stringmap
map
[
string
]
string
stringmap
map
[
string
]
string
bytes
[]
byte
bytes
[]
byte
iface
interface
{}
iface
interface
{}
ifaceptr
interface
{}
}
}
func
(
s
*
S
)
pointerMethod
()
string
{
return
"ptrmethod!"
}
func
(
s
*
S
)
pointerMethod
()
string
{
return
"ptrmethod!"
}
...
@@ -385,6 +386,11 @@ var tests = []*Test{
...
@@ -385,6 +386,11 @@ var tests = []*Test{
out
:
"[1 2 3]"
,
out
:
"[1 2 3]"
,
},
},
&
Test
{
in
:
"{.section ifaceptr}{item} {value}{.end}"
,
out
:
"Item Value"
,
},
}
}
func
TestAll
(
t
*
testing
.
T
)
{
func
TestAll
(
t
*
testing
.
T
)
{
...
@@ -423,6 +429,7 @@ func testAll(t *testing.T, parseFunc func(*Test) (*Template, os.Error)) {
...
@@ -423,6 +429,7 @@ func testAll(t *testing.T, parseFunc func(*Test) (*Template, os.Error)) {
s
.
stringmap
[
"stringkey2"
]
=
"stringresult"
s
.
stringmap
[
"stringkey2"
]
=
"stringresult"
s
.
bytes
=
[]
byte
(
"hello"
)
s
.
bytes
=
[]
byte
(
"hello"
)
s
.
iface
=
[]
int
{
1
,
2
,
3
}
s
.
iface
=
[]
int
{
1
,
2
,
3
}
s
.
ifaceptr
=
&
T
{
"Item"
,
"Value"
}
var
buf
bytes
.
Buffer
var
buf
bytes
.
Buffer
for
_
,
test
:=
range
tests
{
for
_
,
test
:=
range
tests
{
...
...
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