func SdNotify(state string) error {
	addr := &net.UnixAddr{
		Net:  "unixgram",
		Name: os.Getenv("NOTIFY_SOCKET"),
	}
	if addr.Name == "" {
		return nil
	}
	conn, err := net.DialUnix(addr.Net, nil, addr)
	if err != nil {
		return err
	}
	defer conn.Close()
	if _, err = conn.Write([]byte(state)); err != nil {
		return err
	}
	return nil
}
SdNotify sends a message to systemd using the sd_notify protocol.
See https://www.freedesktop.org/software/systemd/man/sd_notify.html.
package systemd  
import (
	"fmt"
	"net"
	"os"
	"strconv"
	"time"
)
const (
	SdNotifyReady = "READY=1"
	SdNotifyWatchdog = "WATCHDOG=1"
)
func HasNotifySocket() bool {
	return os.Getenv("NOTIFY_SOCKET") != ""
}
func HasSystemdWatchdog() bool {
	return os.Getenv("WATCHDOG_USEC") != ""
}
func WatchdogInterval() (time.Duration, error) {
	s, err := strconv.Atoi(os.Getenv("WATCHDOG_USEC"))
	if err != nil {
		return 0, fmt.Errorf(`systemd: error converting WATCHDOG_USEC: %v`, err)
	}
	if s <= 0 {
		return 0, fmt.Errorf(`systemd: error WATCHDOG_USEC must be a positive number`)
	}
	return time.Duration(s) * time.Microsecond, nil
}