Documentation ¶
Index ¶
- Constants
- Variables
- func CopyDir(dst, src string) error
- func CreateFiles(infoList globals.ScaffoldInfoTListT) error
- func GetNamedPath(dirPath string, searchPathFragment string) (string, error)
- func GetRecipePath(absPathToRecipe string, reset bool) string
- func IsDir(path string) bool
- func IsFile(path string) bool
- func ReadJsonFile(filePath string) (map[string]interface{}, error)
- func ReplaceUsingTemplateMap(templateMap map[string]string, dirpath string) error
- func RunTemplate(templateText string, tmplRootData globals.SubstitionTemplateT) (string, error)
- func RunTemplateExpt(data map[string]map[string][]string, templateText string, ...) (string, error)
- type Record
Constants ¶
View Source
const CONTENT_END = "}}"
View Source
const CONTENT_START = "{{"
Variables ¶
View Source
var GetFirstFilePathInRootDir = func(rootDirPath string) (string, error) { firstFilePath := "" err := filepath.WalkDir(rootDirPath, func(s string, d fs.DirEntry, err error) error { if err != nil { return err } if !d.IsDir() { firstFilePath = s return filepath.SkipDir } return nil }) return firstFilePath, err }
View Source
var GetFirstLineOfFirstFile = func(templateMap map[string]string) (string, string, error) { storePath := filepath.Join(templateMap[globals.KEY_ALTER_PATH], globals.STORE_DIRNAME) if !IsDir(storePath) { err := fmt.Errorf("store-path %s does not exist", storePath) return "", "", err } firstFilePath, err := GetFirstFilePathInRootDir(storePath) if err != nil { return "", "", err } wordList, err := GetWordsFromFile(firstFilePath) if err != nil { return "", "", err } firstWordInFirstFile := wordList[0] return firstFilePath, firstWordInFirstFile, nil }
View Source
var GetMoveItemMap = func(templateMap map[string]string) (map[string]globals.MoveItemDetailsT, error) { moveItemMap := make(map[string]globals.MoveItemDetailsT) moveItems := templateMap[globals.KEY_MOVE_ITEMS] moveItemParts := strings.Split(moveItems, ":") lastIndexOfMoveItems := len(moveItemParts) - 1 index := 0 for _, moveItemVal := range moveItemParts { isLastItem := false if index == lastIndexOfMoveItems { isLastItem = true } moveItemKey := strings.Replace(moveItemVal, ".", "_", -1) MoveItemDetails := globals.MoveItemDetailsT{Key: moveItemKey, Index: index, IsLastItem: isLastItem, IsFirstItem: index == 0} moveItemMap[moveItemVal] = MoveItemDetails index++ } return moveItemMap, nil }
View Source
var GetWordsFromFile = func(filePath string) ([]string, error) { file, err := os.Open(filePath) if err != nil { panic(err) } defer file.Close() scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanWords) // Scan all words from the file. var words []string for scanner.Scan() { words = append(words, scanner.Text()) } if err := scanner.Err(); err != nil { return nil, err } return words, nil }
Functions ¶
func CreateFiles ¶
func CreateFiles(infoList globals.ScaffoldInfoTListT) error
func GetRecipePath ¶
func ReadJsonFile ¶
func ReplaceUsingTemplateMap ¶
func RunTemplate ¶
func RunTemplate(templateText string, tmplRootData globals.SubstitionTemplateT) (string, error)
Types ¶
Click to show internal directories.
Click to hide internal directories.