All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m6s
Test / Hakurei (push) Successful in 3m19s
Test / Hpkg (push) Successful in 3m54s
Test / Sandbox (race detector) (push) Successful in 4m17s
Test / Hakurei (race detector) (push) Successful in 5m19s
Test / Flake checks (push) Successful in 1m39s
The mutex is not really doing anything, none of these methods make sense when called concurrently anyway. The copylocks analysis is still satisfied by the noCopy struct. Signed-off-by: Ophestra <cat@gensokyo.uk>
48 lines
715 B
Go
48 lines
715 B
Go
package system
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Enablement represents an optional host service to export to the target user.
|
|
type Enablement byte
|
|
|
|
const (
|
|
EWayland Enablement = 1 << iota
|
|
EX11
|
|
EDBus
|
|
EPulse
|
|
|
|
EM
|
|
)
|
|
|
|
func (e Enablement) String() string {
|
|
switch e {
|
|
case 0:
|
|
return "(no enablements)"
|
|
case EWayland:
|
|
return "wayland"
|
|
case EX11:
|
|
return "x11"
|
|
case EDBus:
|
|
return "dbus"
|
|
case EPulse:
|
|
return "pulseaudio"
|
|
default:
|
|
buf := new(strings.Builder)
|
|
buf.Grow(32)
|
|
|
|
for i := Enablement(1); i < EM; i <<= 1 {
|
|
if e&i != 0 {
|
|
buf.WriteString(", " + i.String())
|
|
}
|
|
}
|
|
|
|
if buf.Len() == 0 {
|
|
return fmt.Sprintf("e%x", byte(e))
|
|
}
|
|
return strings.TrimPrefix(buf.String(), ", ")
|
|
}
|
|
}
|