Skip to content

Commit

Permalink
simplify code gen by moving into meta package
Browse files Browse the repository at this point in the history
  • Loading branch information
dhubler committed Jan 25, 2020
1 parent a31e8a9 commit 03282d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions meta/core.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:generate go run core_gen_main.go

package meta

import (
Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions meta/gen/gen.go → meta/core_gen_main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// +build ignore

// core_gen generates boilerplate functions for meta structs looking
// at specfic field names and generating functions based on that.

package main

import (
Expand All @@ -9,11 +14,9 @@ import (
"text/template"
)

//go:generate go run .

func main() {
elems := buildElements()
tmplFile, err := os.Open("gen.in")
tmplFile, err := os.Open("core_gen.in")
if err != nil {
panic(err)
}
Expand All @@ -25,7 +28,7 @@ func main() {
if err != nil {
panic(err)
}
codeGen, err := os.Create("../core_gen.go")
codeGen, err := os.Create("./core_gen.go")
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -63,7 +66,7 @@ type elem struct {

func buildElements() []*elem {
fset := token.NewFileSet()
src, err := parser.ParseFile(fset, "../core.go", nil, 0)
src, err := parser.ParseFile(fset, "./core.go", nil, 0)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 03282d0

Please sign in to comment.