From b2cedc6c95bb2c88f97875ce803b928ac5729cc6 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Sun, 8 Sep 2019 10:12:02 -0700 Subject: [PATCH] entc: move bindata files to internal packages Summary: godoc was showing "Code generated by go-bindata. (generated) DO NOT EDIT." in the package description and exposing its methods. Reviewed By: alexsn Differential Revision: D17253564 fbshipit-source-id: c82082b4fa6adfba2c2663efbfacefb6423f89d9 --- entc/gen/graph.go | 1 + entc/gen/{ => internal}/bindata.go | 2 +- entc/gen/template.go | 8 +++++--- entc/load/{ => internal}/bindata.go | 2 +- entc/load/load.go | 7 ++++--- 5 files changed, 12 insertions(+), 8 deletions(-) rename entc/gen/{ => internal}/bindata.go (99%) rename entc/load/{ => internal}/bindata.go (99%) diff --git a/entc/gen/graph.go b/entc/gen/graph.go index 702aa3d7f..06a8f84de 100644 --- a/entc/gen/graph.go +++ b/entc/gen/graph.go @@ -2,6 +2,7 @@ // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. +// Package gen is the interface for generating loaded schemas into a Go package. package gen import ( diff --git a/entc/gen/bindata.go b/entc/gen/internal/bindata.go similarity index 99% rename from entc/gen/bindata.go rename to entc/gen/internal/bindata.go index acaaeeccf..2cfa669f2 100644 --- a/entc/gen/bindata.go +++ b/entc/gen/internal/bindata.go @@ -41,7 +41,7 @@ // template/predicate.tmpl // template/tx.tmpl // template/where.tmpl -package gen +package internal import ( "bytes" diff --git a/entc/gen/template.go b/entc/gen/template.go index e6211f314..a1c3245ca 100644 --- a/entc/gen/template.go +++ b/entc/gen/template.go @@ -12,9 +12,11 @@ import ( "path/filepath" "strconv" "text/template" + + "github.com/facebookincubator/ent/entc/gen/internal" ) -//go:generate go-bindata -pkg=gen ./template/... +//go:generate go-bindata -o=internal/bindata.go -pkg=internal ./template/... var ( // Templates holds the template information for a file that the graph is generating. @@ -108,8 +110,8 @@ var ( func init() { templates.Funcs(funcs) - for _, asset := range AssetNames() { - templates = template.Must(templates.Parse(string(MustAsset(asset)))) + for _, asset := range internal.AssetNames() { + templates = template.Must(templates.Parse(string(internal.MustAsset(asset)))) } b := bytes.NewBuffer([]byte("package main\n")) check(templates.ExecuteTemplate(b, "import", Type{}), "load imports") diff --git a/entc/load/bindata.go b/entc/load/internal/bindata.go similarity index 99% rename from entc/load/bindata.go rename to entc/load/internal/bindata.go index e33f370dc..135a35a80 100644 --- a/entc/load/bindata.go +++ b/entc/load/internal/bindata.go @@ -2,7 +2,7 @@ // sources: // template/main.tmpl // schema.go -package load +package internal import ( "bytes" diff --git a/entc/load/load.go b/entc/load/load.go index 87808ad60..ebdc31fc0 100644 --- a/entc/load/load.go +++ b/entc/load/load.go @@ -25,6 +25,7 @@ import ( "time" "github.com/facebookincubator/ent" + "github.com/facebookincubator/ent/entc/load/internal" "github.com/pkg/errors" "golang.org/x/tools/go/packages" @@ -189,13 +190,13 @@ func indirectType(typ types.Type) types.Type { } } -//go:generate go-bindata -pkg=load ./template/... schema.go +//go:generate go-bindata -pkg=internal -o=internal/bindata.go ./template/... schema.go var buildTmpl = templates() func templates() *template.Template { tmpl := template.New("templates").Funcs(template.FuncMap{"base": filepath.Base}) - tmpl = template.Must(tmpl.Parse(string(MustAsset("template/main.tmpl")))) + tmpl = template.Must(tmpl.Parse(string(internal.MustAsset("template/main.tmpl")))) // turns the schema file and its imports into templates. tmpls, err := schemaTemplates() if err != nil { @@ -215,7 +216,7 @@ func schemaTemplates() ([]string, error) { code bytes.Buffer fset = token.NewFileSet() ) - f, err := parser.ParseFile(fset, name, string(MustAsset(name)), parser.AllErrors) + f, err := parser.ParseFile(fset, name, string(internal.MustAsset(name)), parser.AllErrors) if err != nil { return nil, errors.WithMessagef(err, "parse file: %s", name) }