Skip to content

Commit

Permalink
Use go templates to generate code
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Feb 7, 2018
1 parent 41f7497 commit 9e99c14
Show file tree
Hide file tree
Showing 13 changed files with 920 additions and 1,004 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.go]
indent_style = tab

[*.twig]
indent_style = tab
39 changes: 39 additions & 0 deletions cmd/ggraphqlc/basedir.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"fmt"
"os"
"os/user"
"path/filepath"
"strings"
)

var templateDir = func() string {
var gopath = os.Getenv("GOPATH")
if gopath == "" {
usr, err := user.Current()
if err != nil {
fmt.Fprintf(os.Stderr, "cannot determine home dir: %s\n", err.Error())
os.Exit(1)
}
gopath = filepath.Join(usr.HomeDir, "go")
}
for _, path := range strings.Split(gopath, ":") {
if path != "" {
abspath, _ := filepath.Abs(filepath.Join(path, "src", "github.com", "vektah", "graphql-go"))
fmt.Println(abspath)
if dirExists(abspath) {
return abspath
}
}
}

fmt.Fprintln(os.Stderr, "cannot determine base of github.com/vektah/grapqhl-go")
os.Exit(1)
return ""
}()

func dirExists(path string) bool {
fi, err := os.Stat(path)
return !os.IsNotExist(err) && fi.IsDir()
}
326 changes: 0 additions & 326 deletions cmd/ggraphqlc/dumper.go

This file was deleted.

Loading

0 comments on commit 9e99c14

Please sign in to comment.