fix filenames, set up go generate

This commit is contained in:
Ben Kraft
2020-02-06 18:51:44 -08:00
parent b739b6ab5c
commit 0dcd124c8e
4 changed files with 10 additions and 4 deletions
+1 -2
View File
@@ -17,8 +17,7 @@ csilvers is Craig Silverstein
It's already checked in to github, but to generate `generated.go`:
```sh
rm example/generated.go
go run ./cmd/genql/main.go example/genql.yaml
go generate ./...
```
## Generating the schema files
+2
View File
@@ -60,3 +60,5 @@ func Main() {
}
fmt.Println(username, "is", *userResp.User.TheirName)
}
//go:generate go run github.com/Khan/genql genql.yaml
+6 -2
View File
@@ -4,6 +4,8 @@ import (
"bytes"
"fmt"
"go/format"
"path/filepath"
"runtime"
"strings"
"text/template"
@@ -12,9 +14,11 @@ import (
)
// TODO: package template into the binary using one of those asset thingies
const tmplFilename = "generate/operation.go.tmpl"
var _, thisFilename, _, _ = runtime.Caller(0)
var tmplRelFilename = "operation.go.tmpl"
var tmplAbsFilename = filepath.Join(filepath.Dir(thisFilename), tmplRelFilename)
var tmpl = template.Must(template.ParseFiles(tmplFilename))
var tmpl = template.Must(template.ParseFiles(tmplAbsFilename))
type templateParams struct {
// The name of the package into which to generate the operation-helpers.
+1
View File
@@ -1,3 +1,4 @@
// package main is at the root to allow "go run github.com/Khan/genql"
package main
import (