Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text/template: cannot traverse into unexported embedded fields to get exported fields anymore #13885

rsc opened this issue Jan 8, 2016 · 2 comments


Copy link

@rsc rsc commented Jan 8, 2016

After the reflect shuffling, text/template rejects .foo.Bar where foo is an unexported embedded field holding Bar. It probably should allow it (since reflect does too) but still reject plain .foo.

This is simplified from a real test failure.

$ cat x.go
package main

import (

func main() {
    type foo struct {
        Bar int
    type X struct {
    t := template.Must(template.New("").Parse("{{.foo.Bar}}\n"))
    err := t.Execute(os.Stdout, new(X))
    if err != nil {
$ go1.5 run x.go
$ go run x.go
2016/01/08 15:55:14 template: :1:6: executing "" at <.foo.Bar>: foo is an unexported field of struct type *main.X
exit status 1
@rsc rsc self-assigned this Jan 8, 2016
@rsc rsc added this to the Go1.6 milestone Jan 8, 2016
Copy link
Contributor Author

@rsc rsc commented Jan 8, 2016

On the other hand, {{.Bar}} works in both releases so maybe people should have to say that instead. Thinking. Will try to find the test failure again. I've misplaced it.

Copy link
Contributor Author

@rsc rsc commented Jan 13, 2016

Given that {{.Bar}} works, closing unless someone has a compelling example.

@rsc rsc closed this Jan 13, 2016
@golang golang locked and limited conversation to collaborators Jan 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.