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

Exposing folder to go_binary #3786

Open
GRVYDEV opened this issue Dec 14, 2023 · 1 comment
Open

Exposing folder to go_binary #3786

GRVYDEV opened this issue Dec 14, 2023 · 1 comment

Comments

@GRVYDEV
Copy link

GRVYDEV commented Dec 14, 2023

What version of rules_go are you using?

0.42.0

What version of gazelle are you using?

0.33.0

What version of Bazel are you using?

7.0.0

Does this issue reproduce with the latest releases of all the above?

N/A

What operating system and processor architecture are you using?

macOS arm

Any other potentially useful information about your toolchain?

What did you do?

I have a folder structure like this

servers/
    api/
       main.go
       BUILD.bazel
       web/
            ...misc HTML files

I am trying to read files in the web folder in the resulting go binary. My build file is this:

load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
    name = "api_lib",
    srcs = ["main.go"],
    importpath = "github.com/GRVYDEV/quantic/servers/api",
    visibility = ["//visibility:private"],
    deps = [
        "//internal/server",
        "@com_github_weaviate_weaviate//entities/models",
        "@com_github_weaviate_weaviate_go_client_v4//weaviate",
        "@com_github_weaviate_weaviate_go_client_v4//weaviate/graphql",
    ],
)

go_binary(
    name = "api",
    embed = [":api_lib"],
    data = glob(["web/**"]),
    visibility = ["//visibility:public"],
)

The web folder is not getting put next to the resulting binary. I am doing something wrong here but I am unsure how to properly do this. Thanks in advance for any help.

@fmeum
Copy link
Member

fmeum commented Dec 14, 2023

This should be working. Could you share a self-contained reproducer? Also take a look at @rules_go//go/runfiles, a library that helps you find data files at runtime.

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

No branches or pull requests

2 participants