All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m8s
Test / Hakurei (push) Successful in 2m59s
Test / Hpkg (push) Successful in 3m56s
Test / Sandbox (race detector) (push) Successful in 4m28s
Test / Hakurei (race detector) (push) Successful in 5m4s
Test / Flake checks (push) Successful in 1m21s
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(), ", ")
|
|
}
|
|
}
|