Documentation

Overview

    Package entc provides an interface for interacting with entc (ent codegen) as a package rather than an executable.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func Generate

    func Generate(schemaPath string, cfg *gen.Config, options ...Option) (err error)

      Generate runs the codegen on the schema path. The default target directory for the assets, is one directory above the schema path. Hence, if the schema package resides in "<project>/ent/schema", the base directory for codegen will be "<project>/ent".

      If no storage driver provided by option, SQL driver will be used.

      entc.Generate("./ent/path", &gen.Config{
      	Header: "// Custom header",
      	IDType: &field.TypeInfo{Type: field.TypeInt},
      })
      

      func LoadGraph

      func LoadGraph(schemaPath string, cfg *gen.Config) (*gen.Graph, error)

        LoadGraph loads the schema package from the given schema path, and constructs a *gen.Graph.

        Types

        type Option

        type Option func(*gen.Config) error

          Option allows for managing codegen configuration using functional options.

          func FeatureNames

          func FeatureNames(names ...string) Option

            FeatureNames enables sets of features by their names.

            func Storage

            func Storage(typ string) Option

              Storage sets the storage-driver type to support by the codegen.

              func TemplateDir

              func TemplateDir(path string) Option

                TemplateDir parses the template definitions from the files in the directory and associates the resulting templates with codegen templates.

                func TemplateFiles

                func TemplateFiles(filenames ...string) Option

                  TemplateFiles parses the named files and associates the resulting templates with codegen templates.

                  func TemplateGlob

                  func TemplateGlob(pattern string) Option

                    TemplateGlob parses the template definitions from the files identified by the pattern and associates the resulting templates with codegen templates.

                    Source Files

                    Directories

                    Path Synopsis
                    Package gen is the interface for generating loaded schemas into a Go package.
                    Package gen is the interface for generating loaded schemas into a Go package.
                    integration
                    ent
                    Package load is the interface for loading schema package into a Go program.
                    Package load is the interface for loading schema package into a Go program.