v1.16.7
ADDED: * uuidx FIXED: * sprigx docs consistency
This commit is contained in:
47
tplx/sprigx/funcs_tpl_netipx.go
Normal file
47
tplx/sprigx/funcs_tpl_netipx.go
Normal file
@@ -0,0 +1,47 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user