gosod

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: MIT Imports: 1 Imported by: 105

README

gosod

An application scaffold library.

Installation

go get github.com/leaanthony/gosod

Usage

  1. Define a template directory
  2. Define some data
  3. Extract to a target directory
package main

import (
	"log"

	"github.com/leaanthony/gosod"
)

type config struct {
	Name string
}

func main() {

	// Define a new Template directory
	basic, err := gosod.TemplateDir("./myTemplate")
	if err != nil {
		log.Fatal(err)
	}

	// Make some config data
	myConfig := &config{
		Name: "Mat",
	}

	// Create a new directory using the template and config
	err = basic.Extract("./generated", myConfig)
	if err != nil {
		log.Fatal(err)
	}
}

Template Directories

A template directory is simply a directory structure contianing files you wish to copy. The algorithm for copying is:

  • Categorise all files into one of: directory, standard file and template files
    • Create the directory structure
    • Copy standard files
    • Copy template files, assembled using the given data

Template files, by default, are any file with ".tmpl" in their filename. To change this, use SetTemplateFilters([]string). This allows you to set any number of filters.

Files may also be ignored by using the IgnoreFilename(string) method.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemplateDir

func TemplateDir(directoryPath string) (*templatedir.TemplateDir, error)

TemplateDir creates a new TemplateDir structure for the given directoryPath

Types

This section is empty.

Directories

Path Synopsis
examples
basic command
filters command
ignore command
internal

Jump to

Keyboard shortcuts

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