Navigation Menu

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

cmd/go: embed directive doesn't work in file with leading bom #46198

Closed
kasini3000 opened this issue May 17, 2021 · 2 comments
Closed

cmd/go: embed directive doesn't work in file with leading bom #46198

kasini3000 opened this issue May 17, 2021 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@kasini3000
Copy link

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

Golang version with bug:
go version go1.16.4 windows/amd64
go version go1.16.3 windows/amd64
go version go1.16.3 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
win,linux

What did you do?

embed file in win,linux

What did you expect to see?

abcd1111

What did you see instead?

invalid go:embed: build system did not supply embed configuration


go source file allows utf8 with bom, all my go source code is in this format. It works well until it hits go://embed!

This problem has bothered me for a month. I was discussing it in the Golang Technology Park in China,
and @del-xiong discovered the problem. Thanks him! ! !

Golang version with bug:

go version go1.16.4 windows/amd64
go version go1.16.3 windows/amd64
go version go1.16.3 linux/amd64

golang source code:

package main

import (
	_ "embed"
	"fmt"
)

//go:embed h1.txt
var sss string

func main() {
	fmt.Println(sss)
}

error message:

xxx.go:8:3: invalid go:embed: build system did not supply embed configuration

how to let problem gone

Currently,
change xxx.go source file format,from utf8withbom ,to utf8nobom,
line end is CRLF no need change.

h1.txt content:

abcd1111

@seankhliao seankhliao changed the title embed not work bug when utf8bom source file cmd/go: embed directive doesn't work in file with leading bom May 17, 2021
@seankhliao
Copy link
Member

related #35726

cc @jayconrod @bcmills @matloob

@jayconrod jayconrod added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels May 17, 2021
@jayconrod jayconrod added this to the Backlog milestone May 17, 2021
@bcmills bcmills added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 18, 2021
@gopherbot gopherbot removed the NeedsFix The path to resolution is known, but the work has not been done. label May 18, 2021
unbyte added a commit to unbyte/go that referenced this issue Jun 8, 2021
Leading BOM can cause the parsing of go:embed to fail.
Fixes golang#46198
unbyte added a commit to unbyte/go that referenced this issue Jun 8, 2021
Leading BOM can cause the parsing of go:embed to fail.
Fixes golang#46198
@gopherbot
Copy link

Change https://golang.org/cl/325990 mentions this issue: internal/cfg: ignore UTF8 BOM when reading files

unbyte added a commit to unbyte/go that referenced this issue Jun 8, 2021
Leading BOM can cause the parsing of go:embed to fail.
Fixes golang#46198
unbyte added a commit to unbyte/go that referenced this issue Jun 8, 2021
Leading BOM can cause the parsing of go:embed to fail.

Fixes golang#46198
@bcmills bcmills modified the milestones: Backlog, Go1.17 Jun 15, 2021
@golang golang locked and limited conversation to collaborators Jun 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants