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

go/build: embed reader does not handle a rune literal containing a doublequote character #49514

Closed
kenshaw opened this issue Nov 11, 2021 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@kenshaw
Copy link

kenshaw commented Nov 11, 2021

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

$ go version
go version go1.17.3 linux/amd64

Also checked on a macOS and Windows VM, and had the same issue.

Does this issue reproduce with the latest release?

Yes. Additionally, this was checked on go1.17.3 on a macOS and Windows VM and generated the same error.

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ken/.cache/go-build"
GOENV="/home/ken/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ken/src/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ken/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.3"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1579404788=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Attempt to build / compile a go:embed statement after a rune declaration of '"':

package y

import (
	_ "embed"
)

var x = '"'

//go:embed a.txt
var afile []byte

What did you expect to see?

No error.

What did you see instead?

ken@ken-desktop:~/y$ go build
# y
./y.go:9:3: invalid go:embed: build system did not supply embed configuration

It's worth noting that this compiles without issue:

package y

import (
	_ "embed"
)

var x = 'a'

//go:embed a.txt
var afile []byte

This also compiles without issue:

package y

import (
	_ "embed"
)

//go:embed a.txt
var afile []byte

var x = '"'
@ianlancetaylor ianlancetaylor changed the title embed: issue using go:embed after a rune '"' declaration go/build: embed reader does not handle a rune literal containing a doublequote character Nov 11, 2021
@ianlancetaylor
Copy link
Contributor

Nice example. I'm pretty sure it's a bug in the go/build package when it looks for go:embed comments.

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 11, 2021
@ianlancetaylor ianlancetaylor added this to the Go1.18 milestone Nov 11, 2021
@gopherbot
Copy link

Change https://golang.org/cl/363275 mentions this issue: go/build: skip rune literals when looking for go:embed

@golang golang locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants