golang/go

x/tools/internal/imports: import embed in files containing go:embed directives

Open

#50,414 opened on Jan 3, 2022

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
FeatureRequestNeedsFixToolshelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Gopls version info:

Does this issue reproduce with the latest release?

yes

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

What did you do?

import (
	"strings"
	"testing"
)

//go:embed generate/CL/cl.h
var clSource string

What did you expect to see?

gopls via x/tools/internal/imports should add an import _ "embed", because the file requires it for the package to build.

What did you see instead?

No import added. The package fails to compile when running go test because ./manual_test.go:8:3: go:embed only allowed in Go files that import "embed".

@gopherbot Please add label FeatureRequest

Contributor guide