Embed data files in the binary (#180)

Now that we're on Go 1.16+ we can do this easily! The main advantage is
it means users can build a genqlient binary and use that portably (or we
could distribute one, or whatever). Plus the code is marginally simpler;
the `embed` API is really quite nice.

Fixes #9.

Test plan:
```
make check
go build .
rm -rf generate               # pretend we have no checkout
./genqlient ./internal/integration/genqlient.yaml
./genqlient --init            # fails after generating a default config
```
This commit is contained in:
Ben Kraft
2022-03-22 12:00:56 -07:00
committed by GitHub
parent 13094c3e58
commit 36e86cf97f
4 changed files with 14 additions and 29 deletions
+2 -2
View File
@@ -124,7 +124,7 @@ func TestGenerate(t *testing.T) {
}
}
func defaultConfig(t *testing.T) *Config {
func getDefaultConfig(t *testing.T) *Config {
// Parse the config that `genqlient --init` generates, to make sure that
// works.
var config Config
@@ -151,7 +151,7 @@ func TestGenerateWithConfig(t *testing.T) {
baseDir string // relative to dataDir
config *Config // omits Schema and Operations, set below.
}{
{"DefaultConfig", "", defaultConfig(t)},
{"DefaultConfig", "", getDefaultConfig(t)},
{"Subpackage", "", &Config{
Generated: "mypkg/myfile.go",
}},