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