From 2f95327892de43fe77ee596a116471ae9c927b6d Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 6 Aug 2018 12:14:16 -0400 Subject: [PATCH] Move code generator into its own package. --- cmd/pgen/main.go | 4 +++- cmd/pgen/gen.go => generate/generate.go | 2 +- {cmd/pgen => generate}/template.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) rename cmd/pgen/gen.go => generate/generate.go (99%) rename {cmd/pgen => generate}/template.go (97%) diff --git a/cmd/pgen/main.go b/cmd/pgen/main.go index 1485719..876e316 100644 --- a/cmd/pgen/main.go +++ b/cmd/pgen/main.go @@ -11,6 +11,8 @@ import ( "path/filepath" "regexp" "strings" + + "gitlab.wow.st/gmp/persist/generate" ) type visitor struct{} @@ -133,7 +135,7 @@ func main() { if len(ts) == 0 { continue } - g := NewGenerator(pkg.Name) + g := generate.NewGenerator(pkg.Name) for _,v := range ts { g.Add(v.fun, v.name, v.typ) } diff --git a/cmd/pgen/gen.go b/generate/generate.go similarity index 99% rename from cmd/pgen/gen.go rename to generate/generate.go index c13cb4c..537fd2f 100644 --- a/cmd/pgen/gen.go +++ b/generate/generate.go @@ -1,4 +1,4 @@ -package main +package generate import ( "io" diff --git a/cmd/pgen/template.go b/generate/template.go similarity index 97% rename from cmd/pgen/template.go rename to generate/template.go index 34d499a..5cb991d 100644 --- a/cmd/pgen/template.go +++ b/generate/template.go @@ -1,4 +1,4 @@ -package main +package generate const template string = `//Generated by gitlab.wow.st/persist/cmd/pgen. //Do not edit package main