Skip to content

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

Closed as not planned

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

Activity

  1. adonovan commented on Nov 15, 2024

    @adonovan
    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
    }
    
  2. 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[/+] on Nov 15, 2024
  3. seankhliao commented on Nov 15, 2024

    @seankhliao
    Member

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

  4. locked and limited conversation to collaborators on Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions