Categorygithub.com/techdecaf/templates
modulepackage
0.5.4
Repository: https://github.com/techdecaf/templates.git
Documentation: pkg.go.dev

# README

Template Functions

Examples

Operating System Helpers

  • OS {{OS}} resolves to current running os runtime.GOOS
  • ARCH {{ARCH}} resolves to current processor architecture runtime.GOARCH

File and Path Functions

  • PWD {{PWD}} resolves to current working directory
  • FromSlash {{FromSlash}} uses go function filepath.FromSlash
  • ToSlash {{ToSlash}} uses go function filepath.ToSlash
  • ReadFile {{ReadFile}} read file contents, supports relative or absolute paths.
  • WriteFile {{WriteFile 'file/path' 'string data'}} write file contents, supports relative or absolute paths.
  • RemoveAll {{RemoveAll 'file/path'}} CAUTION removes file or folder and all children
  • MkdirAll {{MkdirAll}}
  • Touch {{Touch}}

String Functions

  • ToTitle {{ToTitle}} uses go function strings.Title
  • ToUpper {{ToUpper}} uses go function strings.ToUpper
  • ToLower {{ToLower}} uses go function strings.ToLower
  • Replace {{Replace}} uses go function strings.Replace

Execution Functions

EXEC

{{EXEC `echo "hello"`}}

TRY

{{TRY `fails` | default `default value`}}

Expand

{{Expand}}

ExpandFile

{{ReadFile `my-template-file.yaml` | ExpandFile | WriteFile}}

JQ

{{JQ 'key.value[0]', '{"key": {"value":[1]} }'}}
{{ReadFile `my-file.json` | JQ `key.value[0]`}}

YQ

{{ReadFile `my-file.yaml` | YQ `key.value[0]`}}

# Packages

No description provided by the author

# Functions

Expand Template String.
ExpandFile and return as a string.
GlobMatch.
Run - run command.
SearchJSON a jmespath implementation for go.
SearchYAML converts yaml to JSON and runs a jmespath search.

# Structs

CommandOptions - new command runner.
ExpandOptions to use when expanding a string.
Functions template function map.
Variable struct.
Variables struct.