FIXED:
* *Some* documentation weirdness on pkg.go dev rendering. It still uses
  the Markdown render by default, and it seems if you use anchor links
  in a bulletpoint list, pandoc just says "lol screw you"...

ADDED:
* tplx/sprigx tpl function `osHostname`
This commit is contained in:
brent saner
2026-01-28 09:16:18 -05:00
parent 927ad08057
commit d092f62d11
2 changed files with 116 additions and 79 deletions

View File

@@ -21,11 +21,22 @@ SprigX are extensions to https://masterminds.github.io/sprig/[the `sprig` librar
They provide functions that offer more enriched use cases and domain-specific data.
[TIP]
====
If you are reading this README on the Go Module Directory documentation (https://pkg.go.dev/r00t2.io/goutils/tplx/sprigx)
or the directory landing page (https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx), it may not render correctly.
Be sure to view it at properly via https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx/README.adoc[the AsciiDoc rendering^]
or by downloading and viewing the https://git.r00t2.io/r00t2/go_goutils/raw/branch/master/tplx/sprigx/README.html[HTML version^].
====
[id="use"]
== How do I Use SprigX?
The same way you would `sprig`!
[%collapsible]
.The same way you would `sprig`!
.Like this.
====
[source,go]
----
@@ -53,8 +64,10 @@ var (
----
====
They can even be combined/used together.
[%collapsible]
.They can even be combined/used together.
.Like this.
====
[source,go]
----
@@ -93,8 +106,10 @@ If a `<template>.FuncMap` is added via `.Funcs()` *after* template parsing, it w
For example, if both `sprig` and `sprigx` provide a function `foo`:
this will use `foo` from `sprigx`
[%collapsible]
.this will use `foo` from `sprigx`
.(show)
====
[source,go]
----
@@ -123,10 +138,10 @@ var (
----
====
whereas
whereas this will use `foo` from `sprig`
[%collapsible]
.this will use `foo` from `sprig`
.(show)
====
[source,go]
----
@@ -155,10 +170,10 @@ var (
----
====
and a function can even be
and a function can even be explicitly overridden.
[%collapsible]
.explicitly overridden.
.(show)
====
This would override a function `foo` and `foo2` in `sprigx` from `foo` and `foo2` from `sprig`, but leave all other `sprig` functions untouched.
@@ -201,8 +216,17 @@ var (
== Functions
Expect this list to grow over time, and potentially more frequently than the `sprigx` functions.
[id="fn_os"]
=== Operating System
[id="fn_os_hstnm"]
==== `osHostname`
`osHostname` simply wraps and returns the result of calling https://pkg.go.dev/os#Hostname[`os.Hostname`^].
As such, it comes with the same caveats - it's possible for it to error, and it isn't guaranteed to be an FQDN -- it will be precisely/exactly whatever the kernel's hostname is set as.
[id="fn_sys"]
=== System/OS/Platform
=== System/Platform/Architecture
[id="fn_sys_arch"]
==== `sysArch`

View File

@@ -0,0 +1,13 @@
package sprigx
import (
"os"
)
// osHostname returns os.Hostname()
func osHostname() (out string, err error) {
out, err = os.Hostname()
return
}