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

language/go: generate embedsrcs attribute from //go:embed directive #989

Closed
jayconrod opened this issue Feb 1, 2021 · 0 comments · Fixed by #997
Closed

language/go: generate embedsrcs attribute from //go:embed directive #989

jayconrod opened this issue Feb 1, 2021 · 0 comments · Fixed by #997

Comments

@jayconrod
Copy link
Contributor

This is the Gazelle half of bazel-contrib/rules_go#2775.

Gazelle should recognize embed directives like this (added in Go 1.16):

import "embed"

//go:embed static/*
var staticFiles embed.FS

Gazelle should match embed patterns against files in the current directory, then list those files in an embedsrcs attribute, which would make them available for embedding.

go_library(
    name = "server",
    importpath = "example.com/server",
    srcs = ["server.go"],
    embedsrcs = [
        "a.html",
        "b.html",
    ],
)
jayconrod pushed a commit to jayconrod/bazel-gazelle that referenced this issue Feb 24, 2021
Needed by embedsrcs: files that will not be included in a module are
not embeddable.

* go get golang.org/x/mod@v0.4.1
* go mod tidy
* go mod vendor
* Manually update deps.bzl and directives in WORKSPACE
* go run ./internal/list_repository_tools_srcs.go -generate internal/go_repository_tools_srcs.bzl
* bazel run //:gazelle

For bazel-contrib#989
jayconrod pushed a commit to jayconrod/bazel-gazelle that referenced this issue Feb 24, 2021
jayconrod pushed a commit that referenced this issue Mar 8, 2021
…997)

Also, add a dependency on golang.org/x/mod@v0.4.1 since we need to check whether file names are valid for embedding.

Fixes #989
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant