descriptor

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	// Name is Field Name.
	Name string
	// Kind id Field data type.
	Kind reflect.Kind
	// Fields is child Fields.
	Fields []*Field
}

Field is Field in json.

type File

type File struct {
	Name      string
	PkgName   string
	RawFields map[string]interface{}
}

File is source file infomation.

type OutputFile

type OutputFile struct {
	Name   string
	Writer io.Writer
	File   *ast.File
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a registry of information.

func NewRegistry

func NewRegistry(pkg string) *Registry

NewRegistry returns a new Registry.

func (*Registry) GetOutputPath

func (reg *Registry) GetOutputPath() string

GetOutputPath set package name of generated models.

func (*Registry) GetWriter

func (reg *Registry) GetWriter() io.Writer

GetWriter return writer.

func (*Registry) Load

func (reg *Registry) Load() ([]*File, error)

Load walks through all files having suffix ".json" in the directory specified by path and returns a list of descriptor.File.

func (*Registry) SetFile

func (reg *Registry) SetFile(filename string)

SetFile set input file path to Registry. This method also extract input dir path which is prefix of path to the file.

func (*Registry) SetFiles

func (reg *Registry) SetFiles(f []string)

SetFiles set files to read to Registry.

func (*Registry) SetFilesInDir

func (reg *Registry) SetFilesInDir(path string) error

SetFilesInDir walks through files in inputDirPath and add JSON file to files list.

func (*Registry) SetInputDirPath

func (reg *Registry) SetInputDirPath(path string)

SetInputDirPath set input dir path to Registry.

func (*Registry) SetOutputPath

func (reg *Registry) SetOutputPath(path string)

SetOutputPath set package name of generated models.

func (*Registry) SetPackageName

func (reg *Registry) SetPackageName(pkg string)

SetPackageName set package name of generated models.

func (*Registry) SetWriter

func (reg *Registry) SetWriter(w io.Writer)

SetWriter set writer applicable for all files.

func (*Registry) SetupInput

func (reg *Registry) SetupInput(dirOrFilePath string) error

SetupInput verify path of input and handle based on if it's file path or dir path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL