boilermaker

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 8 Imported by: 1

README

boilermaker

A Go boilerplate generator, similar to Yeoman or CookieCutter.

Uses text/template under the hood to handle templating.

Usage

Check out the example folder for usage within Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMapFS

func ParseMapFS(fsys fs.FS, dir string) (map[string]*Boilerplate, error)

ParseMapFS parses a set of boilerplate directories. it expects that the file structure is as follows:

  • one
  • one/example
  • two
  • two/something_else

and these will be parsed as boilerplates 'one' and 'two'

Types

type Boilerplate

type Boilerplate struct {
	Template *template.Template
	Metadata Metadata
}

func ParseFS

func ParseFS(fsys fs.FS) (*Boilerplate, error)

func (Boilerplate) Generate

func (bp Boilerplate) Generate(data any) (Result, error)

Generate a map of files for the boilerplate.

func (*Boilerplate) ParseMetadata

func (b *Boilerplate) ParseMetadata(fsys fs.FS, path string) error

type Metadata

type Metadata struct {
	Description string `json:"description"`
}

type Result

type Result map[string]string

Result is a map of filenames to file contents.

func (Result) Write

func (r Result) Write(dir string) error

Write the generated files to disk

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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