Skip to content

text/template: can't evaluate field a in type *main.A #29137

@mei-rune

Description

@mei-rune

What version of Go are you using (go version)?

$ go version
go version go1.11.1 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxxx\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=d:\developing\go\xxxxx;
set GOPROXY=
set GORACE=
set GOROOT=d:\tools\go_amd64
set GOTMPDIR=
set GOTOOLDIR=d:\tools\go_amd64\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build794245338=/tmp/go-build -gno-record-gcc-switche
s

What did you do?

// You can edit this code!
// Click here and start typing.
package main

import (
 "fmt"
 "text/template"
 "os"
)

type A struct {
  Name string
}

func main() {
	var a *A = nil

	err := template.Must(template.New("default").Parse("{{.Name}}")).Execute(os.Stdout, a)
	if err != nil {
		fmt.Println(err)
	}
}

What did you expect to see?

template: default:1:4: executing "default" at <.Name>: nil pointer evaluating .Name

What did you see instead?

template: default:1:4: executing "default" at <.Name>: can't evaluate field Name in type *main.A

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions