bazel-contrib / bazel-contrib/rules_go

Exposing folder to go_binary

Open
#3,786 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### 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.

Contributor guide

Open the contributing guide

Research direction

Start with servers/api/BUILD.bazel, especially the go_binary data attribute and its glob over web/**; compare that setup with how main.go accesses the files. Confirm the issue is resolved when the web folder's contents are available alongside the resulting api binary at runtime.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.