mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
And generate the ServiceInfo struct from the Swagger spec. Signed-off-by: Cory Snider <csnider@mirantis.com>
26 lines
600 B
Go
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()
|
|
}
|