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

A text template rendering fine on 1.13 causes an error on 1.14rc1 #37066

Closed
misha-ridge opened this issue Feb 5, 2020 · 3 comments
Closed

A text template rendering fine on 1.13 causes an error on 1.14rc1 #37066

misha-ridge opened this issue Feb 5, 2020 · 3 comments

Comments

@misha-ridge
Copy link

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

$ go version
go version go1.14rc1 darwin/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
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/dottedmag/go/bin"
GOCACHE="/Users/dottedmag/Library/Caches/go-build"
GOENV="/Users/dottedmag/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="github.com/ridge"
GONOSUMDB="github.com/ridge"
GOOS="darwin"
GOPATH="/Users/dottedmag/go"
GOPRIVATE="github.com/ridge"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/dottedmag/tectonic/_deps/go-1.14rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/dottedmag/tectonic/_deps/go-1.14rc1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bw/6hyp_vyj68v973qbhlbcvlcr0000gn/T/go-build655686198=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Run https://play.golang.org/p/8iAJIxRlZpR with go 1.14rc1.

What did you expect to see?

X<nil>

What did you see instead?

template: :1:5: executing "" at <(len .X) gt 0>: can't give argument to non-function len .X

@misha-ridge misha-ridge changed the title A text template rendered by 1.13 causes an error on 1.14rc1 A text template rendering fine by 1.13 causes an error on 1.14rc1 Feb 5, 2020
@misha-ridge misha-ridge changed the title A text template rendering fine by 1.13 causes an error on 1.14rc1 A text template rendering fine on 1.13 causes an error on 1.14rc1 Feb 5, 2020
@ianlancetaylor
Copy link
Member

This is a bug fix. Your template is

{{if (len .X) gt 0}}X{{end}}

That doesn't make sense. You almost certainly meant

{{if gt (len.X) 0}}X{{end}}

But enough people get this wrong that this fix should be in the release notes, and it isn't. I'll add it.

@misha-ridge
Copy link
Author

Oh, thanks. This is a shortened template from go-swagger.

Reported there: go-swagger/go-swagger#2215

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/217978 mentions this issue: doc/go1.14: mention better error checking in text/template

@golang golang locked and limited conversation to collaborators Feb 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants