// newUserSystemdDbus creates a connection for systemd user-instance. func newUserSystemdDbus() (*systemdDbus.Conn, error) { … } // DetectUID detects UID from the OwnerUID field of `busctl --user status` // if running in userNS. The value corresponds to sd_bus_creds_get_owner_uid(3) . // // Otherwise returns os.Getuid() . func DetectUID() (int, error) { … } // DetectUserDbusSessionBusAddress returns $DBUS_SESSION_BUS_ADDRESS, if set. // Otherwise it returns "unix:path=$XDG_RUNTIME_DIR/bus", if $XDG_RUNTIME_DIR/bus exists. func DetectUserDbusSessionBusAddress() (string, error) { … }