-
-
Notifications
You must be signed in to change notification settings - Fork 707
Description
Go 1.16 allows embedding files within a compiled package by imported the embed
package and using one or more //go:embed
directives. For example:
package main
import (
_ "embed"
"fmt"
)
func main() {
//go:embed quine.go
var s string
fmt.Print(s)
}
rules_go should support this.
go_library
, go_binary
, go_test
, and perhaps also go_proto_library
should support a new embedsrcs
attribute specifying a list of targets that could provide embeddable files. It's unfortunate we can't just call it embed
, but that already means something else.
The rules should pass these files to the builder, which should match the //go:embed
patterns against these files to produce an embedcfg
file, which may be passed to the compiler.
The builder should produce a sensible error messages if //go:embed
directives are used Go versions lower than 1.16.
Until this is implemented, go_embed_data
may be used instead.