Skip to content

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

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

Closed
clearcodecn opened this issue Nov 15, 2024 · 3 comments
Closed

Comments

@clearcodecn
Copy link

clearcodecn commented Nov 15, 2024

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

@adonovan
Copy link
Member

Is this actually a bug? The Go scanner works in the exact same way:
https://go.dev/play/p/PCwzdxqPyD9

package main

func main() {
    /* println("*/") */                       error: newline in string
}

@adonovan adonovan changed the title text/template: Annotation parsing error, annotation symbols within the string should not be parsed text/template: quoted "*/" within a /*...*/ comment terminates the comment Nov 15, 2024
@seankhliao
Copy link
Member

I'd agree that this is working as intended and covered by the usual rules for "Comments do not nest ".

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants