diff --git a/slicesx/doc.go b/slicesx/doc.go index c7b5619..9b48f3d 100644 --- a/slicesx/doc.go +++ b/slicesx/doc.go @@ -1,4 +1,7 @@ /* Package slicesx aims to extend functionality of the stdlib [slices] module. + +Most are convenience functions that aid in readability (sometimes at a VERY negligible performance hit), +but others can be quite useful (e.g. [Remove], [RemoveAll], [RemoveReverse]) that will save on significant boilerplate. */ package slicesx diff --git a/slicesx/funcs.go b/slicesx/funcs.go index dcefdb6..fd4f7c7 100644 --- a/slicesx/funcs.go +++ b/slicesx/funcs.go @@ -1,10 +1,51 @@ package slicesx +import ( + `slices` +) + +/* +First returns the first item/element in slice s. + +e will be the nil/zero value of the slice element type +if the slice length is 0 (including if s == nil). +*/ +func First[S ~[]E, E any](s S) (e E) { + + if len(s) == 0 { + return + } + + e = s[0] + + return +} + +/* +FirstIndex returns the index of the first element in slice s. + +While at first glance this may seem useless, it may have some usecases as instead of causing panics: + + * If s is empty, idx will be -1. + * If s is nil, idx will be -2. + * Otherwise idx will ALWAYS be 0. +*/_ +func FirstIndex[S ~[]E, E any](s S) (idx int) { + + if s == nil { + idx = -2 + } else if len(s) == 0 { + idx = -1 + } + + return +} + /* Last returns the last item/element in slice s. e will be the nil/zero value of the slice element type -if the slice length is 0. +if the slice length is 0 (including if s == nil). */ func Last[S ~[]E, E any](s S) (e E) { @@ -41,3 +82,107 @@ func LastIndex[S ~[]E, E any](s S) (idx int) { return } + +/* +Remove removes any values of value elem from slice s up to max number of elems. + +If maxRemove is negative (< 0), start from the end instead. +This simply wraps [RemoveReverse]: + + removed = slicesx.RemoveReverse(s, elem, uint(-maxRemove)) + +If maxRemove is exactly 0, remove ALL instances of elem. + +If s is nil, removed will be nil as well. + +Note that s will remain untouched, and removed will be a new slice. +*/ +func Remove[S ~[]E, E comparable](s S, elem E, maxRemove int) (removed S) { + + var idx int + + if s == nil { + return + } + if len(s) == 0 { + removed = []E{} + return + } + + removed = make(S, 0, len(s)) + defer func() { + if removed != nil { + removed = slices.Clip(removed) + } + }() + + if maxRemove < 0 { + removed = RemoveReverse(s, elem, uint(-maxRemove)) + return + } else if maxRemove == 0 { + maxRemove = len(s) + } + + for idx = range s { + if s[idx] == elem && maxRemove > 0 { + maxRemove-- + continue + } + removed = append(removed, s[idx]) + } + + return +} + +/* +RemoveAll is simply a convenience wrapper around [Remove], e.g.: + + removed = slicesx.Remove(s, elem, 0) +*/ +func RemoveAll[S ~[]E, E comparable](s S, elem E) (removed S) { return Remove(s, elem, 0) } + +/* +RemoveReverse removes any values of value elem from slice s up to max number of elems in reverse order +(i.e. starting from the END of s). + +If maxRemove is exactly 0, remove all instances of elem (via [RemoveAll]), i.e.: + + removed = slicesx.RemoveAll(s, elem) + // or, more directly: + removed = slicesx.Remove(s, elem, 0) + +If s is nil, removed will be nil as well. + +Note that s will remain untouched, and removed will be a new slice. +*/ +func RemoveReverse[S ~[]E, E comparable](s S, elem E, maxRemove uint) (removed S) { + + var idx int + + if s == nil { + return + } + if len(s) == 0 { + removed = []E{} + return + } + + if maxRemove == 0 { + removed = RemoveAll(s, elem) + return + } + + removed = make(S, 0, len(s)) + + for idx = len(s) - 1; idx >= 0; idx-- { + if s[idx] == elem && maxRemove > 0 { + maxRemove-- + continue + } + removed = append(removed, s[idx]) + } + removed = slices.Clip(removed) + slices.Reverse(removed) + + return +} diff --git a/tplx/sprigx/README.html b/tplx/sprigx/README.html index 557fe5b..ac3ed10 100644 --- a/tplx/sprigx/README.html +++ b/tplx/sprigx/README.html @@ -636,7 +636,7 @@ pre.rouge .gs {
Brent Saner
bts@square-r00t.net
-Last rendered 2026-08-08 00:30:44 -0400 +Last rendered 2026-09-03 16:25:31 -0400
Table of Contents
diff --git a/tplx/sprigx/README.md b/tplx/sprigx/README.md index 2d8d8e1..7629678 100644 --- a/tplx/sprigx/README.md +++ b/tplx/sprigx/README.md @@ -4,9 +4,9 @@
-Brent Saner - -Last rendered 2026-08-08 00:30:48 -0400 +Brent Saner\ +\ +Last rendered 2026-09-03 16:25:36 -0400
@@ -305,7 +305,7 @@ To re-render all docs (including [PDF](#rndr_pdf)):
-``` rouge +``` git clone https://git.r00t2.io/r00t2/go_goutils.git cd go_goutils .githooks/pre-commit/01-docgen @@ -329,7 +329,7 @@ HTML output is re-rendered and included in git -``` rouge +``` git clone https://git.r00t2.io/r00t2/go_goutils.git cd go_goutils export orig_dir="$(pwd)" @@ -363,7 +363,7 @@ To render as PDF:
-``` rouge +``` git clone https://git.r00t2.io/r00t2/go_goutils.git cd go_goutils export orig_dir="$(pwd)" @@ -401,7 +401,7 @@ Like this.
-``` rouge +``` package main import ( @@ -445,7 +445,7 @@ like this.
-``` rouge +``` package main import ( @@ -508,7 +508,7 @@ this will use `foo` from `sprigx`
-``` rouge +``` package main import ( @@ -547,7 +547,7 @@ whereas this will use `foo` from `sprig`
-``` rouge +``` package main import ( @@ -598,7 +598,7 @@ This would override a function `foo` and `foo2` in `sprigx` from `foo` and `foo2
-``` rouge +``` package main import ( @@ -667,7 +667,7 @@ Function Signature
-``` rouge +``` func CombinedFuncMap(preferSprigX bool) (fmap map[string]any) ``` @@ -709,7 +709,7 @@ Function Signature
-``` rouge +``` func CombinedHtmlFuncMap(preferSprigX bool) (fmap template.FuncMap) ``` @@ -745,7 +745,7 @@ Function Signature
-``` rouge +``` func CombinedTxtFuncMap(preferSprigX bool) (fmap template.FuncMap) ``` @@ -781,7 +781,7 @@ Function Signature
-``` rouge +``` func FuncMap() (fmap map[string]any) ``` @@ -817,7 +817,7 @@ Function Signature
-``` rouge +``` func HtmlFuncMap() (fmap template.FuncMap) ``` @@ -847,7 +847,7 @@ Function Signature
-``` rouge +``` func Nop(obj ...any) (s string) ``` @@ -883,7 +883,7 @@ Function Signature
-``` rouge +``` func TxtFuncMap() (fmap template.FuncMap) ``` @@ -959,7 +959,7 @@ Function Signature
-``` rouge +``` func dump(a ...interface{}) (out string) ``` @@ -995,7 +995,7 @@ Function Signature
-``` rouge +``` func metaIsNil(obj any) (isNil bool) ``` @@ -1019,9 +1019,7 @@ This function fills in the gap that - [id="fn_net_all"] - === Networking - These template functions use capabilities from: +\[id="fn_net_all"\] === Networking These template functions use capabilities from:
@@ -1073,7 +1071,7 @@ Function Signature
-``` rouge +``` func netCidrMask(ones, bits int) (mask net.IPMask) ``` @@ -1103,7 +1101,7 @@ Function Signature
-``` rouge +``` func netExtractAddr(s string) (addr net.IP, err error) ``` @@ -1133,7 +1131,7 @@ Function Signature
-``` rouge +``` func netExtractHost(hostPort string) (host string, err error) ``` @@ -1163,7 +1161,7 @@ Function Signature
-``` rouge +``` func netExtractIpnet(s string) (ipNet *net.IPNet, err error) ``` @@ -1193,7 +1191,7 @@ Function Signature
-``` rouge +``` func netExtractPort(hostPort string) (port uint16, err error) ``` @@ -1223,7 +1221,7 @@ Function Signature
-``` rouge +``` func netIfaces() (ifaces []net.Interface, err error) ``` @@ -1253,7 +1251,7 @@ Function Signature
-``` rouge +``` func netIp4Mask(a, b, c, d any) (mask net.IPMask, err error) ``` @@ -1277,7 +1275,7 @@ It is wrapped so that `a`, `b`, `c`, and `d` may be a string:
-``` rouge +``` {{- $mask := netIp4Mask "198" "51" "100" "10" -}} ``` @@ -1295,7 +1293,7 @@ or integers/other numeric:
-``` rouge +``` {{- $mask := netIp4Mask 198 51 100 10 -}} ``` @@ -1313,7 +1311,7 @@ or bytes:
-``` rouge +``` {{- $mask := netIp4Mask 0xc6 0x33 0x64 0x0a -}} ``` @@ -1331,7 +1329,7 @@ or even a mix:
-``` rouge +``` {{- $mask := netIp4Mask "198" 51 "100" 0x0a -}} ``` @@ -1355,7 +1353,7 @@ Function Signature
-``` rouge +``` func netJoinHostPort(host, port string) (out string) ``` @@ -1385,7 +1383,7 @@ Function Signature
-``` rouge +``` func netParseIP(s string) (ip net.IP) ``` @@ -1427,7 +1425,7 @@ Function Signature
-``` rouge +``` func netipAddrPort(ip netip.Addr, port uint16) (addrPort netip.AddrPort) ``` @@ -1457,7 +1455,7 @@ Function Signature
-``` rouge +``` func netipParseAddr(s string) (addr netip.Addr, err error) ``` @@ -1487,7 +1485,7 @@ Function Signature
-``` rouge +``` func netipParseAddrPort(s string) (addrPort netip.AddrPort, err error) ``` @@ -1517,7 +1515,7 @@ Function Signature
-``` rouge +``` func netipParsePrefix(s string) (pfx netip.Prefix, err error) ``` @@ -1547,7 +1545,7 @@ Function Signature
-``` rouge +``` func netipPrefix(ip netip.Addr, bits int) (pfx netip.Prefix) ``` @@ -1589,7 +1587,7 @@ Function Signature
-``` rouge +``` func netipxAddrIpNet(addr netip.Addr) (ipNet *net.IPNet) ``` @@ -1619,7 +1617,7 @@ Function Signature
-``` rouge +``` func netipxCmpPfx(a, b netip.Prefix) (cmp int) ``` @@ -1649,7 +1647,7 @@ Function Signature
-``` rouge +``` func netipxFromStdAddr(ip net.IP, port int, zone string) (addrPort netip.AddrPort, err error) ``` @@ -1679,7 +1677,7 @@ Function Signature
-``` rouge +``` func netipxFromIp(ip net.IP) (addr netip.Addr, err error) ``` @@ -1709,7 +1707,7 @@ Function Signature
-``` rouge +``` func netipxFromIpNet(ipNet *net.IPNet) (pfx netip.Prefix, err error) ``` @@ -1739,7 +1737,7 @@ Function Signature
-``` rouge +``` func netipxParseRange(s string) (ipRange netipx.IPRange, err error) ``` @@ -1769,7 +1767,7 @@ Function Signature
-``` rouge +``` func netipxPfxAddr(s string) (addr netip.Addr, err error) ``` @@ -1799,7 +1797,7 @@ Function Signature
-``` rouge +``` func netipxPfxIpNet(pfx netip.Prefix) (ipNet *net.IPNet) ``` @@ -1829,7 +1827,7 @@ Function Signature
-``` rouge +``` func netipxPfxLast(pfx netip.Prefix) (addr netip.Addr) ``` @@ -1859,7 +1857,7 @@ Function Signature
-``` rouge +``` func netipxPfxRange(pfx netip.Prefix) (ipRange netipx.IPRange) ``` @@ -1889,7 +1887,7 @@ Function Signature
-``` rouge +``` func netipxRange(from, to netip.Addr) (ipRange netipx.IPRange) ``` @@ -1931,7 +1929,7 @@ Function Signature
-``` rouge +``` func netxAddrRfc(addr netip.Addr) (rfcStr string) ``` @@ -1961,7 +1959,7 @@ Function Signature
-``` rouge +``` func netxAddrRfc(cidr uint8) (ipMask net.IPMask, err error) ``` @@ -1991,7 +1989,7 @@ Function Signature
-``` rouge +``` func netxCidr4Mask(cidr uint8) (mask uint32, err error) ``` @@ -2021,7 +2019,7 @@ Function Signature
-``` rouge +``` func netxCidr4Str(cidr uint8) (maskStr string, err error) ``` @@ -2051,7 +2049,7 @@ Function Signature
-``` rouge +``` func netxFamilyVer(family uint16) (ipVer int) ``` @@ -2081,7 +2079,7 @@ Function Signature
-``` rouge +``` func netxGetAddrFam(addr netip.Addr) (family uint16) ``` @@ -2111,7 +2109,7 @@ Function Signature
-``` rouge +``` func netxGetIpFam(ip net.IP) (family uint16) ``` @@ -2141,7 +2139,7 @@ Function Signature
-``` rouge +``` func netxIpRfc(ip net.IP) (rfcStr string) ``` @@ -2171,7 +2169,7 @@ Function Signature
-``` rouge +``` func netxIpRfcStr(s string) (rfcStr string) ``` @@ -2201,7 +2199,7 @@ Function Signature
-``` rouge +``` func netxIpStripRfc(s string) (stripStr string) ``` @@ -2231,7 +2229,7 @@ Function Signature
-``` rouge +``` func netxIp4MaskCidr(ipMask net.IPMask) (cidr uint8, err error) ``` @@ -2261,7 +2259,7 @@ Function Signature
-``` rouge +``` func netxIp4MaskMask(ipMask net.IPMask) (mask uint32, err error) ``` @@ -2291,7 +2289,7 @@ Function Signature
-``` rouge +``` func netxIp4MaskStr(ipMask net.IPMask) (maskStr string, err error) ``` @@ -2321,7 +2319,7 @@ Function Signature
-``` rouge +``` func netxIpVerStr(s string) (ipVer int) ``` @@ -2351,7 +2349,7 @@ Function Signature
-``` rouge +``` func netxIsBrktd6(s string) (isBrktdIp bool) ``` @@ -2381,7 +2379,7 @@ Function Signature
-``` rouge +``` func netxIsIp(s string) (isIp bool) ``` @@ -2411,7 +2409,7 @@ Function Signature
-``` rouge +``` func netxIsPfx(s string) (isNet bool) ``` @@ -2441,7 +2439,7 @@ Function Signature
-``` rouge +``` func netxMask4Cidr(mask uint32) (cidr uint8, err error) ``` @@ -2471,7 +2469,7 @@ Function Signature
-``` rouge +``` func netxMask4StrCidr(maskStr string) (cidr uint8, err error) ``` @@ -2501,7 +2499,7 @@ Function Signature
-``` rouge +``` func netxMask4StrIpMask(maskStr string) (mask net.IPMask, err error) ``` @@ -2531,7 +2529,7 @@ Function Signature
-``` rouge +``` func netxMask4StrMask(maskStr string) (mask uint32, err error) ``` @@ -2561,7 +2559,7 @@ Function Signature
-``` rouge +``` func netxVerFamily(ipVer int) (family uint16) ``` @@ -2603,7 +2601,7 @@ Function Signature
-``` rouge +``` func dnsxPtrAddr(s string) (ip netip.Addr, err error) ``` @@ -2633,7 +2631,7 @@ Function Signature
-``` rouge +``` func dnsxAddrPtr(ip netip.Addr) (s string) ``` @@ -2663,7 +2661,7 @@ Function Signature
-``` rouge +``` func dnsxStrWire(recordNm string) (recordNmBytes []byte, err error) ``` @@ -2693,7 +2691,7 @@ Function Signature
-``` rouge +``` func dnsxWireStr(recordNmBytes []byte) (recordNm string, err error) ``` @@ -2723,7 +2721,7 @@ Function Signature
-``` rouge +``` func dnsxPtrIp(s string) (ip net.IP, err error) ``` @@ -2753,7 +2751,7 @@ Function Signature
-``` rouge +``` func dnsxIpPtr(ip net.IP) (s string) ``` @@ -2783,7 +2781,7 @@ Function Signature
-``` rouge +``` func dnsxIsFqdn(s string) (fqdn bool) ``` @@ -2813,7 +2811,7 @@ Function Signature
-``` rouge +``` func dnsxIsTxt(fqdn string) (isOk bool) ``` @@ -2843,7 +2841,7 @@ Function Signature
-``` rouge +``` func dnsxIsNsec3(s string) (maybeNsec3 bool) ``` @@ -2873,7 +2871,7 @@ Function Signature
-``` rouge +``` func dnsxIsSrv(s string) (srv bool) ``` @@ -2903,7 +2901,7 @@ Function Signature
-``` rouge +``` func dnsxIsWild(s string) (wildcard bool) ``` @@ -2933,7 +2931,7 @@ Function Signature
-``` rouge +``` func dnsxIsLbl(s string) (isLbl bool) ``` @@ -2963,7 +2961,7 @@ Function Signature
-``` rouge +``` func dnsxIsPtr(s string) (isPtr bool, addr net.IP) ``` @@ -3001,7 +2999,7 @@ Function Signature
-``` rouge +``` func numFloat32Str(f float32) (s string) ``` @@ -3031,7 +3029,7 @@ Function Signature
-``` rouge +``` func numFloat64(val any) (f float64, err error) ``` @@ -3061,7 +3059,7 @@ Function Signature
-``` rouge +``` func numFloat64Str(f float64) (s string) ``` @@ -3091,7 +3089,7 @@ Function Signature
-``` rouge +``` func numFloatStr(val any) (s string, err error) ``` @@ -3133,7 +3131,7 @@ Function Signature
-``` rouge +``` func osFQDN() (fqdn string, err error) ``` @@ -3181,7 +3179,7 @@ Function Signature
-``` rouge +``` func osGroupById[T string | int](gid T) (g *user.Group, err error) ``` @@ -3217,7 +3215,7 @@ Function Signature
-``` rouge +``` func osGroupByName(grpNm string) (g *user.Group, err error) ``` @@ -3253,7 +3251,7 @@ Function Signature
-``` rouge +``` func osHost() (out string, err error) ``` @@ -3277,7 +3275,7 @@ e.g.:
-``` rouge +``` {{- $fqdn := osFQDN -}} {{- $h := osHost -}} {{- $cmp := index ($fqdn | splitList ".") 0 -}} @@ -3331,7 +3329,7 @@ Function Signature
-``` rouge +``` func osHostname() (out string, err error) ``` @@ -3361,7 +3359,7 @@ Function Signature
-``` rouge +``` func osIdState() (idst sysutils.IDState) ``` @@ -3418,7 +3416,7 @@ Function Signature
-``` rouge +``` func osUser() (u *user.User, err error) ``` @@ -3454,7 +3452,7 @@ Function Signature
-``` rouge +``` func osUserById[T string | int](uid T) (u *user.User, err error) ``` @@ -3490,7 +3488,7 @@ Function Signature
-``` rouge +``` func osUserByName(userNm string) (u *user.User, err error) ``` @@ -3542,7 +3540,7 @@ Function Signature
-``` rouge +``` func pathJoin(elem ...string) (out string) ``` @@ -3581,7 +3579,7 @@ Warning
-``` rouge +``` {{- pathJoin "a" "b" "c" }} {{- pathJoin "/" "a" "b" "c" }} {{- pathJoin "/a/b" "c" }} @@ -3601,7 +3599,7 @@ renders as:
-``` rouge +``` a/b/c /a/b/c /a/b/c @@ -3627,7 +3625,7 @@ Function Signature
-``` rouge +``` func pathPipeJoin(elems ...string) (out string) ``` @@ -3651,7 +3649,7 @@ This makes it much more suitable for use in template pipelines, as the previous
-``` rouge +``` {{- $myBase := "/a" -}} {{- pathPipeJoin "b" "c" "a" }} {{- pathPipeJoin "a" "b" "c" "/" }} @@ -3672,7 +3670,7 @@ renders as:
-``` rouge +``` a/b/c /a/b/c /a/b/c @@ -3698,7 +3696,7 @@ Function Signature
-``` rouge +``` func pathSliceJoin(sl []string) (out string) ``` @@ -3737,7 +3735,7 @@ Tip
-``` rouge +``` {{- $myList := "a,b,c" | splitList "," -}} {{- $myList | pathSliceJoin }} {{- ("a,b,c" | splitList ",") | pathSliceJoin }} @@ -3758,7 +3756,7 @@ renders as:
-``` rouge +``` a/b/c a/b/c /a/b/c @@ -3784,7 +3782,7 @@ Function Signature
-``` rouge +``` func pathSlicePipeJoin(sl []string, root string) (out string) ``` @@ -3831,7 +3829,7 @@ Tip
-``` rouge +``` {{- $myBase := "/a" -}} {{- $myList := "b,c,d" | splitList "." -}} {{- pathSlicePipeJoin $myList $myBase }} @@ -3852,7 +3850,7 @@ renders as:
-``` rouge +``` /a/b/c /a/b/c ``` @@ -3877,7 +3875,7 @@ Function Signature
-``` rouge +``` func pathSubJoin(root string, elems ...string) (out string) ``` @@ -3901,7 +3899,7 @@ The pipeline-friendly equivalent of this is [`pathPipeJoin`](#fn_path_gnrc_ppj).
-``` rouge +``` {{- pathSubJoin "/a/b" "c" }} {{- pathSubJoin "/" "a" "b" "c" }} {{- "c" | pathSubJoin "/" "a" "b" }} @@ -3921,7 +3919,7 @@ renders as:
-``` rouge +``` /a/b/c /a/b/c /a/b/c @@ -3983,7 +3981,7 @@ Function Signature
-``` rouge +``` func osPathJoin(elem ...string) (out string) ``` @@ -4022,7 +4020,7 @@ Warning
-``` rouge +``` {{- osPathJoin "a" "b" "c" }} {{- osPathJoin "/" "a" "b" "c" }} {{- osPathJoin "C:\\" "a" "b" "c" }} @@ -4056,7 +4054,7 @@ renders as:
-
a\b\c
+
a\b\c
 \a\b\c
 \a\b\c
 C:\a\b\c
@@ -4070,7 +4068,7 @@ C:a\b\c
-
a/b/c
+
a/b/c
 /a/b/c
 C:\/a/b/c
 C:/a/b/c
@@ -4097,7 +4095,7 @@ Function Signature
-``` rouge +``` func osPathJoin(elems ...string) (out string) ``` @@ -4121,7 +4119,7 @@ This makes it much more suitable for use in template pipelines, as the previous
-``` rouge +``` {{- $myBase := "/a" -}} {{- osPathPipeJoin "b" "c" "a" }} {{- osPathPipeJoin "a" "b" "c" "/" }} @@ -4155,7 +4153,7 @@ renders as:
-
a\b\c
+
a\b\c
 \a\b\c
 \a\b\c
@@ -4167,7 +4165,7 @@ renders as:
-
a/b/c
+
a/b/c
 /a/b/c
 /a/b/c
@@ -4193,7 +4191,7 @@ Function Signature
-``` rouge +``` func osPathSep() (out string) ``` @@ -4211,7 +4209,7 @@ func osPathSep() (out string)
-``` rouge +``` {{- osPathSep }} ``` @@ -4242,7 +4240,7 @@ renders as:
-
\
+
\
@@ -4252,7 +4250,7 @@ renders as:
-
/
+
/
@@ -4276,7 +4274,7 @@ Function Signature
-``` rouge +``` func osPathSliceJoin(sl []string) (out string) ``` @@ -4315,7 +4313,7 @@ Tip
-``` rouge +``` {{- $myList := "a,b,c" | splitList "," -}} {{- $myList | osPathSliceJoin }} {{- ("a,b,c" | splitList ",") | osPathSliceJoin }} @@ -4349,7 +4347,7 @@ renders as:
-
a\b\c
+
a\b\c
 a\b\c
 \a\b\c
@@ -4361,7 +4359,7 @@ a\b\c
-
a/b/c
+
a/b/c
 a/b/c
 /a/b/c
@@ -4387,7 +4385,7 @@ Function Signature
-``` rouge +``` func osPathSlicePipeJoin(sl []string, root string) (out string) ``` @@ -4426,7 +4424,7 @@ Tip
-``` rouge +``` {{- $myBase := "/a" -}} {{- $myList := "b,c,d" | splitList "." -}} {{- osPathSlicePipeJoin $myList $myBase }} @@ -4460,7 +4458,7 @@ renders as:
-
\a\b\c\d
+
\a\b\c\d
 \a\b\c\d
@@ -4471,7 +4469,7 @@ renders as:
-
/a/b/c/d
+
/a/b/c/d
 /a/b/c/d
@@ -4496,7 +4494,7 @@ Function Signature
-``` rouge +``` func osPathSubJoin(root string, elems ...string) (out string) ``` @@ -4520,7 +4518,7 @@ The pipeline-friendly equivalent of this is [`osPathPipeJoin`](#fn_path_os_ppj).
-``` rouge +``` {{- osPathSubJoin "/a/b" "c" }} {{- osPathSubJoin "/" "a" "b" "c" }} {{- "c" | osPathSubJoin "/" "a" "b" }} @@ -4553,7 +4551,7 @@ renders as:
-
\a\b\c
+
\a\b\c
 \a\b\c
 \a\b\c
@@ -4565,7 +4563,7 @@ renders as:
-
/a/b/c
+
/a/b/c
 /a/b/c
 /a/b/c
@@ -4609,7 +4607,7 @@ Function Signature
-``` rouge +``` func psCpuCnts(logical bool) (numCpu int, err error) ``` @@ -4639,7 +4637,7 @@ Function Signature
-``` rouge +``` func psCpuInfo() (cpuInfo []cpu.Info, err error) ``` @@ -4669,7 +4667,7 @@ Function Signature
-``` rouge +``` func psCpuPct(interval time.Duration, percpu bool) (pcts []float64, err error) ``` @@ -4699,7 +4697,7 @@ Function Signature
-``` rouge +``` func psCpuTimes(percpu bool) (cpuTimes []cpu.TimesStat, err error) ``` @@ -4735,7 +4733,7 @@ Function Signature
-``` rouge +``` func psDiskIoCnts(names ...string) (stats map[string]disk.IOCountersStat, err error) ``` @@ -4765,7 +4763,7 @@ Function Signature
-``` rouge +``` func psDiskLabel(name string) (label string, err error) ``` @@ -4795,7 +4793,7 @@ Function Signature
-``` rouge +``` func psDiskParts(all bool) (parts []disk.PartitionStat, err error) ``` @@ -4825,7 +4823,7 @@ Function Signature
-``` rouge +``` func psDiskSerial(name string) (serial string, err error) ``` @@ -4855,7 +4853,7 @@ Function Signature
-``` rouge +``` func psDiskUsage(path string) (usage *disk.UsageStat, err error) ``` @@ -4891,7 +4889,7 @@ Function Signature
-``` rouge +``` func psHostBoot() (bootEpoch uint64, err error) ``` @@ -4921,7 +4919,7 @@ Function Signature
-``` rouge +``` func psHostId() (hostId string, err error) ``` @@ -4951,7 +4949,7 @@ Function Signature
-``` rouge +``` func psHostInfo() (info *host.InfoStat, err error) ``` @@ -4981,7 +4979,7 @@ Function Signature
-``` rouge +``` func psHostKernArch() (arch string, err error) ``` @@ -5011,7 +5009,7 @@ Function Signature
-``` rouge +``` func psHostKernVer() (ver string, err error) ``` @@ -5041,7 +5039,7 @@ Function Signature
-``` rouge +``` func psHostPlatInfo() (platInfo [3]string, err error) ``` @@ -5077,7 +5075,7 @@ Function Signature
-``` rouge +``` func psHostPlatUptime() (uptimeSecs uint64, err error) ``` @@ -5107,7 +5105,7 @@ Function Signature
-``` rouge +``` func psHostUsers() (users []host.UserStat, err error) ``` @@ -5137,7 +5135,7 @@ Function Signature
-``` rouge +``` func psHostPlatVirt() (virtInfo [2]string, err error) ``` @@ -5179,7 +5177,7 @@ Function Signature
-``` rouge +``` func psLoadAvg() (avg *load.AvgStat, err error) ``` @@ -5209,7 +5207,7 @@ Function Signature
-``` rouge +``` func psLoadMisc() (misc *load.MiscStat, err error) ``` @@ -5245,7 +5243,7 @@ Function Signature
-``` rouge +``` func psMemExVMem() (exVMem *mem.ExVirtualMemory, err error) ``` @@ -5331,7 +5329,7 @@ Function Signature
-``` rouge +``` func psMemSwap() (swap *mem.SwapMemoryStat, err error) ``` @@ -5361,7 +5359,7 @@ Function Signature
-``` rouge +``` func psMemSwapDevs() (swapDevs []*mem.SwapDevice, err error) ``` @@ -5391,7 +5389,7 @@ Function Signature
-``` rouge +``` func psMemVMem() (vmem *mem.VirtualMemoryStat, err error) ``` @@ -5427,7 +5425,7 @@ Function Signature
-``` rouge +``` func psNetConns(kind string) (conns []net.ConnectionStat, err error) ``` @@ -5457,7 +5455,7 @@ Function Signature
-``` rouge +``` func psNetConnsMax(kind string, maxConn int) (conns []net.ConnectionStat, err error) ``` @@ -5487,7 +5485,7 @@ Function Signature
-``` rouge +``` func psNetConnsPid(kind string, pid int32) (conns []net.ConnectionStat, err error) ``` @@ -5517,7 +5515,7 @@ Function Signature
-``` rouge +``` func psNetConnsPidMax(kind string, pid int32, maxConn int) (conns []net.ConnectionStat, err error) ``` @@ -5547,7 +5545,7 @@ Function Signature
-``` rouge +``` func psNetCTStats(percCpu bool) (ctStats []net.ConntrackStat, err error) ``` @@ -5577,7 +5575,7 @@ Function Signature
-``` rouge +``` func psNetCTStatList() (ctStats *net.ConntrackStatList, err error) ``` @@ -5607,7 +5605,7 @@ Function Signature
-``` rouge +``` func psNetFilterCnts() (filterCnts []net.FilterStat, err error) ``` @@ -5637,7 +5635,7 @@ Function Signature
-``` rouge +``` func psNetIoCnts(perNIC bool) (ioCnts []net.IOCountersStat, err error) ``` @@ -5667,7 +5665,7 @@ Function Signature
-``` rouge +``` func psNetIoCntsFile(perNIC bool, filepath string) (ioCnts []net.IOCountersStat, err error) ``` @@ -5697,7 +5695,7 @@ Function Signature
-``` rouge +``` func psNetIfaces() (ioCnts []net.InterfaceStatList, err error) ``` @@ -5727,7 +5725,7 @@ Function Signature
-``` rouge +``` func psNetPids() (pids []int32, err error) ``` @@ -5757,7 +5755,7 @@ Function Signature
-``` rouge +``` func psNetProtoCnt(protos []string) (protoCnts []net.ProtoCountersStat, err error) ``` @@ -5808,7 +5806,7 @@ Function Signature
-``` rouge +``` func psNetRev(b []byte) (out []byte) ``` @@ -5865,7 +5863,7 @@ Function Signature
-``` rouge +``` func psProcs(pid int32) (procs []*process.Process, err error) ``` @@ -5895,7 +5893,7 @@ Function Signature
-``` rouge +``` func psProcNew(pid int32) (proc *process.Process, err error) ``` @@ -5925,7 +5923,7 @@ Function Signature
-``` rouge +``` func psProcPids() (pids []int32, err error) ``` @@ -5955,7 +5953,7 @@ Function Signature
-``` rouge +``` func psProcPidExists(pid int32) (exists bool, err error) ``` @@ -5991,7 +5989,7 @@ Function Signature
-``` rouge +``` func psSensorExTemp() (temps []sensors.ExTemperature, err error) ``` @@ -6046,7 +6044,7 @@ Function Signature
-``` rouge +``` func psSensorTemps() (temps []sensors.TemperatureStat, err error) ``` @@ -6103,7 +6101,7 @@ Function Signature
-``` rouge +``` func psWinsvcList() (svcs []winservices.Service, err error) ``` @@ -6154,7 +6152,7 @@ Function Signature
-``` rouge +``` func psWinsvcNew(svcName string) (svc *winservices.Service, err error) ``` @@ -6237,7 +6235,7 @@ Function Signature
-``` rouge +``` func extIndent( levels int, @@ -6391,7 +6389,7 @@ Function Signature
-``` rouge +``` func strsxIsAscii(s string, allowCtl, allowExt bool) (isAscii bool, err error) ``` @@ -6421,7 +6419,7 @@ Function Signature
-``` rouge +``` func strsxIsAsciiBuf(r io.RuneReader, allowCtl, allowExt bool) (isAscii bool, err error) ``` @@ -6451,7 +6449,7 @@ Function Signature
-``` rouge +``` func strsxIsAsciiSpcl( s string, @@ -6489,7 +6487,7 @@ Function Signature
-``` rouge +``` func strsxIsAsciiBufSpcl( r io.RuneReader, @@ -6527,7 +6525,7 @@ Function Signature
-``` rouge +``` func strsxLenSpl(s string, width uint) (out []string) ``` @@ -6557,7 +6555,7 @@ Function Signature
-``` rouge +``` func strsxLenSplStr(s string, width uint, winNewline bool) (out string) ``` @@ -6587,7 +6585,7 @@ Function Signature
-``` rouge +``` func strsxPad(s []string, width uint, pad string, leftPad bool) (out []string) ``` @@ -6617,7 +6615,7 @@ Function Signature
-``` rouge +``` func strsxRedact(s, maskStr string, leading, trailing uint, newlines bool) (redacted string) ``` @@ -6647,7 +6645,7 @@ Function Signature
-``` rouge +``` func strsxRev(s string) (revS string) ``` @@ -6677,7 +6675,7 @@ Function Signature
-``` rouge +``` func strsxTrimLns(s string, left, right bool) (trimmed string) ``` @@ -6707,7 +6705,7 @@ Function Signature
-``` rouge +``` func strsxTrimSpcLft(s string) (trimmed string) ``` @@ -6737,7 +6735,7 @@ Function Signature
-``` rouge +``` func strsxTrimSpcRt(s string) (trimmed string) ``` @@ -6775,7 +6773,7 @@ Function Signature
-``` rouge +``` func sysArch() (out string) ``` @@ -6805,7 +6803,7 @@ Function Signature
-``` rouge +``` func sysNumCpu() (cnt int) ``` @@ -6835,7 +6833,7 @@ Function Signature
-``` rouge +``` func sysOsName() (out string) ``` @@ -6865,7 +6863,7 @@ Function Signature
-``` rouge +``` func sysRuntime() (out map[string]string) ``` @@ -6920,7 +6918,7 @@ Tip | `num_go` | int | | `go_ver` | string | -Table 1. `sysRuntime` Values +Table 1. `sysRuntime` Values {.tableblock .frame-all .grid-all .stretch}
@@ -6984,7 +6982,7 @@ Function Signature
-``` rouge +``` func tmDate(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) (date time.Time) ``` @@ -7014,7 +7012,7 @@ Function Signature
-``` rouge +``` func tmFloatMicro(t time.Time) (f64 float64) ``` @@ -7044,7 +7042,7 @@ Function Signature
-``` rouge +``` func tmFloatMilli(t time.Time) (f64 float64) ``` @@ -7074,7 +7072,7 @@ Function Signature
-``` rouge +``` func tmFloatNano(t time.Time) (f64 float64) ``` @@ -7104,7 +7102,7 @@ Function Signature
-``` rouge +``` func tmFloat(t time.Time) (f64 float64) ``` @@ -7134,7 +7132,7 @@ Function Signature
-``` rouge +``` func tmFmt(fstr string, t time.Time) (out string) ``` @@ -7152,7 +7150,7 @@ func tmFmt(fstr string, t time.Time) (out string)
-``` rouge +``` {{- $t := tmNow -}} {{ $t.Format "" }} ``` @@ -7177,7 +7175,7 @@ Function Signature
-``` rouge +``` func tmNow() (now time.Time) ``` @@ -7207,7 +7205,7 @@ Function Signature
-``` rouge +``` func tmParseDur8n(s string) (d time.Duration, err error) ``` @@ -7237,7 +7235,7 @@ Function Signature
-``` rouge +``` func tmParseMonth(v any) (mon time.Month, err error) ``` @@ -7267,7 +7265,7 @@ Function Signature
-``` rouge +``` func tmParseMonthInt(n any) (mon time.Month, err error) ``` @@ -7355,7 +7353,7 @@ Function Signature
-``` rouge +``` func tmParseMonthStr(s string) (mon time.Month, err error) ``` @@ -7397,7 +7395,7 @@ Function Signature
-``` rouge +``` func tmParseTime(layout, value string) (t time.Time, err error) ```