Skip to content

text/template: quoted "*/" within a /*...*/ comment terminates the comment #70366

Closed as not planned
@clearcodecn

Description

@clearcodecn

Parsing this string with text/template gives an error:

{{/*  print "*/" */}}                 -> error: "comment ends before closing delimiter"

Go version

go version go1.23.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/zmj/Library/Caches/go-build'
GOENV='/Users/zmj/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/zmj/go/pkg/mod'
GONOPROXY='git.dustess.com'
GONOSUMDB='git.dustess.com'
GOOS='darwin'
GOPATH='/Users/zmj/go'
GOPRIVATE='git.dustess.com'
GOPROXY='https://goproxy.io'
GOROOT='/Users/zmj/.gvm/gos/go1.23.2'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/zmj/.gvm/gos/go1.23.2/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/zmj/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='/usr/bin/cc'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/zmj/Desktop/projects/sfshare/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/2d/_qd9vb7n5yqfhxgx57llw8l40000gn/T/go-build685601311=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

https://go.dev/play/p/-jIq4rJbRfG

What did you see happen?

parse template failed:  template: :2: comment ends before closing delimiter

What did you expect to see?

except no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions