Files
moby/daemon/internal/netipstringer/stringer.go
Cory Snider a90adb6dc1 api/types/network: use netip types as appropriate
And generate the ServiceInfo struct from the Swagger spec.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:14 +02:00

26 lines
600 B
Go

// Package netipstringer provides utilities to convert netip types to strings
// which return the empty string for invalid values.
package netipstringer
import (
"net/netip"
)
// Addr returns the string representation of addr.
// The empty string is returned if addr is not valid.
func Addr(addr netip.Addr) string {
if !addr.IsValid() {
return ""
}
return addr.String()
}
// Prefix returns the string representation of prefix.
// The empty string is returned if prefix is not valid.
func Prefix(prefix netip.Prefix) string {
if !prefix.IsValid() {
return ""
}
return prefix.String()
}