Files
go_goutils/tplx/sprigx/funcs_tpl_netipx.go
brent saner 1eea0c2672 v1.16.7
ADDED:
* uuidx
FIXED:
* sprigx docs consistency
2026-02-11 10:21:29 -05:00

48 lines
899 B
Go

package sprigx
import (
`net`
`net/netip`
`go4.org/netipx`
)
// netipxFromStdAddr wraps go4.org/netipx.FromStdAddr to comply with Go template requirements.
func netipxFromStdAddr(ip net.IP, port int, zone string) (addrPort netip.AddrPort, err error) {
var ok bool
if addrPort, ok = netipx.FromStdAddr(ip, port, zone); !ok {
err = ErrBadAddrPort
return
}
return
}
// netipxFromIp wraps go4.org/netipx.FromStdIP to comply with Go template requirements.
func netipxFromIp(ip net.IP) (addr netip.Addr, err error) {
var ok bool
if addr, ok = netipx.FromStdIP(ip); !ok {
err = ErrBadAddr
return
}
return
}
// netipxFromIpNet wraps go4.org/netipx.FromStdIPNet to comply with Go template requirements.
func netipxFromIpNet(ipnet *net.IPNet) (pfx netip.Prefix, err error) {
var ok bool
if pfx, ok = netipx.FromStdIPNet(ipnet); !ok {
err = ErrBadNet
return
}
return
}