scaffold

package
v0.0.0-...-c1737e8 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileAlreadyExists = errors.New("file already exists")
	ErrUnknownAction     = errors.New("unknown action")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// ModulePath is the name of the Go module.
	ModulePath string

	// ProjectName is the name of this project.
	ProjectName string

	// ProtobufSupport signals whether or not to generate the project with
	// protobuf support.
	ProtobufSupport bool
}

type HasModulePath

type HasModulePath interface {
	// InjectModulePath sets the template module path.
	InjectModulePath(string)
}

HasModulePath allows a module path to be used in a template.

type HasProjectName

type HasProjectName interface {
	// InjectProjectName sets the template project name.
	InjectProjectName(string)
}

HasProjectName allows a project name to be used in a template.

type HasProtobufSupport

type HasProtobufSupport interface {
	// InjectProtobufSupport injects the template with protobuf support.
	InjectProtobufSupport(bool)
}

HasProtobufSupport signals that the project should be generated with protobuf support.

type IfExistsAction

type IfExistsAction int

IfExistsAction determines what to do if the scaffold file already exists.

const (
	// Skip skips the file and moves to the next one.
	Skip IfExistsAction = iota

	// Error returns an error and stops processing.
	Error

	// Overwrite overwrites the existing file.
	Overwrite
)

type ModulePathMixin

type ModulePathMixin struct {
	// ModulePath is the name of the Go module.
	ModulePath string
}

func (*ModulePathMixin) InjectModulePath

func (m *ModulePathMixin) InjectModulePath(modulePath string)

InjectModulePath implements HasModulePath.

type ProjectNameMixin

type ProjectNameMixin struct {
	// ProjectName is the name of the project.
	ProjectName string
}

func (*ProjectNameMixin) InjectProjectName

func (m *ProjectNameMixin) InjectProjectName(projectName string)

InjectProjectName implements HasProjectName.

type ProtobufMixin

type ProtobufMixin struct {
	// ProtobufSupport signals that the project should be generated with
	// protobuf support.
	ProtobufSupport bool
}

func (*ProtobufMixin) InjectProtobufSupport

func (m *ProtobufMixin) InjectProtobufSupport(protobufSupport bool)

InjectProtobufSupport implements ProtobufSupport.

type Scaffolder

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

func NewScaffolder

func NewScaffolder() *Scaffolder

func (*Scaffolder) Execute

func (s *Scaffolder) Execute(config *Config, templates ...Template) error

type Template

type Template interface {
	// GetPath returns the path to the file's location.
	GetPath() string

	// GetBody returns the template body.
	GetBody() string

	// GetIfExistsAction determines what to do if the file already exists.
	GetIfExistsAction() IfExistsAction

	// SetTemplateDefaults sets the default values for templates.
	SetTemplateDefaults() error
}

type TemplateMixin

type TemplateMixin struct {
	// Path is the path of the file.
	Path string

	// TemplateBody is the template body to execute.
	TemplateBody string

	// IFExistsAction determines what to do if the file exists.
	IfExistsAction IfExistsAction
}

func (*TemplateMixin) GetBody

func (m *TemplateMixin) GetBody() string

func (*TemplateMixin) GetPath

func (m *TemplateMixin) GetPath() string

Jump to

Keyboard shortcuts

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