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.
Go 1.16 allows embedding files within a compiled package by imported the
embedpackage and using one or more//go:embeddirectives. For example:rules_go should support this.
go_library,go_binary,go_test, and perhaps alsogo_proto_libraryshould support a newembedsrcsattribute specifying a list of targets that could provide embeddable files. It's unfortunate we can't just call itembed, but that already means something else.The rules should pass these files to the builder, which should match the
//go:embedpatterns against these files to produce anembedcfgfile, which may be passed to the compiler.The builder should produce a sensible error messages if
//go:embeddirectives are used Go versions lower than 1.16.Until this is implemented,
go_embed_datamay be used instead.