blob: e7cd8f15b8d80ad112488c32d01702b67171f1a2 [file] [log] [blame] [view]
Hendrik Hofstadt4b0e5c02019-11-07 20:21:24 +01001##Bindata
2
3This rule uses [go-bindata](https://github.com/kevinburke/go-bindata) to package arbitrary go files.
4Please refer to the documentation there on how to use the packaged data.
5
6Generally this rule is very similar to the `bindata` rule in the default go bazel package.
7However this rule also creates an embeddable go library right away.
8
9###How to use
10
11Add the files you want to package to the `srcs` attribute, set the `package` attribute to the
12go package you want the result to be in and embed the rule into a `go_library`.
13
14####Example: Packaging sql migrations
15
16These rules package all `.sql` files into the target and make it accessible at `importpath` in the package `models`.
17```
18
19go_library(
20 name = "go_default_library",
21 embed = [
22 ":migrations_pack",
23 ],
Serge Bazanski31370b02021-01-07 16:31:14 +010024 importpath = "source.monogon.dev/golibs/minijob/generated/sql",
Hendrik Hofstadt4b0e5c02019-11-07 20:21:24 +010025 visibility = ["//visibility:public"],
26)
27
28bindata(
29 name = "migrations_pack",
30 package = "models",
31 srcs = glob(["*.sql"]),
32)
33
34```