Documentation ¶
Index ¶
- Constants
- Variables
- type BaseTemplate
- type Context
- type Docker
- type File
- type FileAppendWriter
- type FileWriter
- type GenerateOptions
- func DockerfileOptions() GenerateOptions
- func DomainErrorsOptions() GenerateOptions
- func FileOptions(name string, tplContext Context, targetPath string) GenerateOptions
- func GitignoreOptions() GenerateOptions
- func K8sDeploymentOptions() GenerateOptions
- func K8sServiceOptions() GenerateOptions
- func MainStubOptions(ctx Context) GenerateOptions
- func MakefileOptions(ctx Context) GenerateOptions
- func MiddlewareOptions() GenerateOptions
- func RequestResponseOptions(ctx Context) GenerateOptions
- func ServiceStubOptions() GenerateOptions
- type Generator
- type Godin
- type Method
- type Partial
- type Project
- type Protobuf
- type Publisher
- type Service
- type Subscriber
- type Template
- type Transport
- type Variable
- type Writer
Constants ¶
const FileExtension = "tpl"
FileExtension defines the template file extension used by Godin
Variables ¶
var PartialTemplates = map[string]string{
"service_method": "partials/service_method.tpl",
"logging_method": "partials/logging_method.tpl",
"request": "partials/request.tpl",
"endpoint": "partials/endpoint.tpl",
"response": "partials/response.tpl",
"grpc_encode_request": "partials/grpc/request_response/encode_request.tpl",
"grpc_encode_response": "partials/grpc/request_response/encode_response.tpl",
"grpc_decode_request": "partials/grpc/request_response/decode_request.tpl",
"grpc_decode_response": "partials/grpc/request_response/decode_response.tpl",
"grpc_request_decoder": "partials/grpc/encode_decode/request_decoder.tpl",
"grpc_request_encoder": "partials/grpc/encode_decode/request_encoder.tpl",
"grpc_response_decoder": "partials/grpc/encode_decode/response_decoder.tpl",
"grpc_response_encoder": "partials/grpc/encode_decode/response_encoder.tpl",
"amqp_publish_encode": "partials/amqp/encode_decode/publish_encode.tpl",
"amqp_subscribe_decode": "partials/amqp/encode_decode/subscribe_decode.tpl",
"amqp_subscribe_decoder_interfaces": "partials/amqp/encode_decode/subscribe_decoder_interfaces.tpl",
}
Functions ¶
This section is empty.
Types ¶
type BaseTemplate ¶
type BaseTemplate struct {
// contains filtered or unexported fields
}
BaseTemplate provides the basic templating functionality required for Godin
func (*BaseTemplate) Filename ¶
func (b *BaseTemplate) Filename() string
Filename returns the filename of the currently loaded template
func (*BaseTemplate) FormatCode ¶
func (b *BaseTemplate) FormatCode(source []byte) ([]byte, error)
FormatCode will use go/format to format the given raw code
func (*BaseTemplate) PartialsGlob ¶
func (b *BaseTemplate) PartialsGlob() string
PartialsGlob returns a glob-path which matches all templates inside the partial folder
func (*BaseTemplate) TemplatePath ¶
func (b *BaseTemplate) TemplatePath() string
TemplatePath returns the absolute template path to the current base template Since packr2: this just returns the filename, the virtual filesystem has a different chroot
type Context ¶
func NewContextFromConfig ¶
func NewContextFromConfig() Context
NewContextFromConfig will initialize the context will all the data from the configuration The context is not fully populated after this call, but all configuration values are accessible.
type File ¶
type File struct { BaseTemplate // contains filtered or unexported fields }
type FileAppendWriter ¶
type FileAppendWriter struct {
Writer
}
func NewFileAppendWriter ¶
func NewFileAppendWriter(path string, data []byte) *FileAppendWriter
NewFileAppendWriter returns a new appending file-writer for Godin templates
func (*FileAppendWriter) Write ¶
func (f *FileAppendWriter) Write() error
Write will open the given file and try to append the given data to it The file is NOT created if it doesn't exist.
type FileWriter ¶
type FileWriter struct {
Writer
}
func NewFileWriter ¶
func NewFileWriter(path string, data []byte) *FileWriter
NewFileWriter initializes a new FileWriter
func (*FileWriter) Write ¶
func (f *FileWriter) Write(overwrite bool) error
Write dumps the given data into a file and creates it if necessary. The overwrite flag can be set to overwrite any existing data.
type GenerateOptions ¶
type GenerateOptions struct { Template string IsGoSource bool Context Context TargetFile string Overwrite bool }
func DockerfileOptions ¶
func DockerfileOptions() GenerateOptions
func DomainErrorsOptions ¶ added in v0.5.0
func DomainErrorsOptions() GenerateOptions
func FileOptions ¶
func FileOptions(name string, tplContext Context, targetPath string) GenerateOptions
func GitignoreOptions ¶
func GitignoreOptions() GenerateOptions
func K8sDeploymentOptions ¶
func K8sDeploymentOptions() GenerateOptions
func K8sServiceOptions ¶
func K8sServiceOptions() GenerateOptions
func MainStubOptions ¶ added in v0.6.0
func MainStubOptions(ctx Context) GenerateOptions
func MakefileOptions ¶ added in v0.6.0
func MakefileOptions(ctx Context) GenerateOptions
func MiddlewareOptions ¶
func MiddlewareOptions() GenerateOptions
func RequestResponseOptions ¶
func RequestResponseOptions(ctx Context) GenerateOptions
func ServiceStubOptions ¶
func ServiceStubOptions() GenerateOptions
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator(opts GenerateOptions) *Generator
type Method ¶
type Method struct { // required for partials which do not have access to the Service struct ServiceName string Comments []string Name string Params []Variable Returns []Variable Request string Response string ProtobufRequest string ProtobufResponse string }
func MethodFromType ¶
func (Method) RequestName ¶
func (Method) ResponseName ¶
func (Method) ReturnImplementationMissing ¶
ReturnImplementationMissing will produce a list of nil returns and an error. For example, the return params are (name string, err error) the method will return "nil, fmt.Errorf("NOT IMPLEMENTED")"
func (Method) ReturnList ¶
func (Method) ReturnVariableList ¶
ReturnVariableList returns all return variable names as comma-separated string
type Partial ¶
type Partial struct { BaseTemplate // contains filtered or unexported fields }
func NewPartial ¶
type Publisher ¶ added in v0.5.0
type Publisher struct { Publishing rabbitmq.Publishing Name string ProtobufMessage string }
type Subscriber ¶ added in v0.5.0
type Subscriber struct { Handler string Subscription rabbitmq.Subscription Protobuf struct { Import string Message string } }