generator

package
v0.0.0-...-7eceb3a Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: MIT Imports: 7 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 string            // name of the field
	Tags map[string]string // tags on the field
}

Field contains the parsed metadata about a struct field, like it's Name and a map of it's Tags.

type StructData

type StructData struct {
	Name          string    // the name of the struct we're looking for
	PkgImportPath string    // the import path for this type
	File          *ast.File // parsed file containing our struct def
	Fields        []Field   // the fields def
}

StructData contains data about this struct that is used during the code generation, such as the struct name and package name such that we could generate things like

package foo

type BarSearchRequest struct {
	// ...
}

StructData also collects the Fields contained with the struct such that we can generate a list of fields that are approved for search or create or update requests like

 	type BarField int

	const (
		Baz BarField = iota
		Boom
		Biff
		Bang
	)

func GatherStructData

func GatherStructData(structName string) (*StructData, error)

GatherStructData finds the correct file containing the struct in question, parses out the pertinents, and then returns the struct data to be used for generating files.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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