From 12482405856b9932efa2f91330fb7a8a2e4aa2d9 Mon Sep 17 00:00:00 2001 From: Grégoire Duchêne Date: Sun, 4 Jul 2021 15:48:31 +0100 Subject: Return ErrNoSDSupport if using dummy code --- socket.go | 11 ++++++++++- socket_dummy.go | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/socket.go b/socket.go index d982812..6603cdc 100644 --- a/socket.go +++ b/socket.go @@ -14,7 +14,16 @@ // is the documentation for the C API. package gosdd -import "os" +import ( + "errors" + "os" +) + +// ErrNoSDSupport is a generic error that is returned when gosdd has no +// systemd support, either because the library is compiled on a system +// that is not Linux or because it was explicitly disabled with the +// ‘nosystemd’ build tag. +var ErrNoSDSupport = errors.New("no systemd support") // SDListenFDs is a wrapper around sd_listen_fds. func SDListenFDs(unsetenv bool) ([]*os.File, error) { diff --git a/socket_dummy.go b/socket_dummy.go index 4311e6c..7b21c82 100644 --- a/socket_dummy.go +++ b/socket_dummy.go @@ -8,9 +8,9 @@ package gosdd import "os" func sdListenFDs(bool) ([]*os.File, error) { - return nil, nil + return nil, ErrNoSDSupport } func sdListenFDsWithNames(bool) (map[string]*os.File, error) { - return nil, nil + return nil, ErrNoSDSupport } -- cgit v1.2.3-70-g09d2