tmpl

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 10 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InfoTime added in v0.10.1

func InfoTime(info string) time.Time

InfoTime will attempting to pull a timestamp from a info string through the query params and file path and name Order of priority and supported formats ?day=2006-01-02 ?hour=2006-01-02T15 ?time=2005-01-02T15:04:05Z file name 20060102T150405.txt path layout 2006/01/02/15 or "2006/01/02 or "2006/01

func Meta added in v0.6.0

func Meta(s string, meta url.Values) string

Meta will parse a template string according to the provided metadata query params all token should be prefixed with meta {meta:key}

func Parse

func Parse(s string, t time.Time) string

Parse will parse a template string according to the provided instance of time.Time. It supports the following template tokens:

{YYYY} (year - four digits: ie 2017) {YY} (year - two digits: ie 17) {MM} (month - two digits: ie 12) {DD} (day - two digits: ie 13) {HH} (hour - two digits: ie 00) {min} (minute - two digits: ie 00) {TS} (timestamp in the format 20060102T150405) {SLUG} (alias of HOUR_SLUG) {HOUR_SLUG} (date hour slug, shorthand for {YYYY}/{MM}/{DD}/{HH}) {DAY_SLUG} (date day slug, shorthand for {YYYY}/{MM}/{DD}) {MONTH_SLUG} (date month slug, shorthand for {YYYY}/{MM}) {HOST} (os hostname) {POD} kubernetes unique pod name {UUID} creates an 8 character unique id

Template values are case sensitive.

Items can be commented out by a hash sign # anything after the # will be ignored

Examples: template: "{YYYY}-{MM}-{DD}T{HH}:00" could return: "2017-01-01T23:00"

template: "{TS}" could return: "20170101T230101"

template: "base/path/{SLUG}/records-{TS}.json.gz" could return: "base/path/2017/01/01/23/records-20170101T230101.json.gz"

func PathTime

func PathTime(pth string) time.Time

PathTime will attempt to extract a time value from the path by the following formats filename - /path/{20060102T150405}.txt hour slug - /path/2006/01/02/15/file.txt day slash slug - /path/2006/01/02/file.txt day dash slug - /path/2006-01-02.txt month slug - /path/2006/01/file.txt

Types

This section is empty.

Jump to

Keyboard shortcuts

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