fix filenames, set up go generate
This commit is contained in:
+1
-2
@@ -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
|
||||
|
||||
@@ -60,3 +60,5 @@ func Main() {
|
||||
}
|
||||
fmt.Println(username, "is", *userResp.User.TheirName)
|
||||
}
|
||||
|
||||
//go:generate go run github.com/Khan/genql genql.yaml
|
||||
|
||||
@@ -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,3 +1,4 @@
|
||||
// package main is at the root to allow "go run github.com/Khan/genql"
|
||||
package main
|
||||
|
||||
import (
|
||||
Reference in New Issue
Block a user