1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
package fqdn
import "fmt"
// Error for cases when os.Hostname() fails.
var ErrHostnameFailed = errHostnameFailed{}
// Error for cases when we could not found fqdn for whatever reason.
var ErrFqdnNotFound = errFqdnNotFound{}
type errHostnameFailed struct {
cause error
}
func (e errHostnameFailed) Error() string {
return fmt.Sprintf("could not get hostname: %v", e.cause)
}
func (e errHostnameFailed) Unwrap() error {
return e.cause
}
func (e errHostnameFailed) Is(target error) bool {
switch target.(type) {
case errHostnameFailed:
return true
default:
return false
}
}
type errFqdnNotFound struct {
cause error
}
func (e errFqdnNotFound) Error() string {
return fmt.Sprintf("fqdn hostname not found: %v", e.cause)
}
func (e errFqdnNotFound) Unwrap() error {
return e.cause
}
func (e errFqdnNotFound) Is(target error) bool {
switch target.(type) {
case errFqdnNotFound:
return true
default:
return false
}
}
|