delve/pkg/proc/macutil/rosetta_darwin.go
Alessandro Arzilli b9fcb03ff4
proc/native,proc/gdbserial: detect and complain about Rosetta (#2569)
Delve does not run under Rosetta. Detect this condition and point
confused users towards the solution.
2021-07-06 08:53:39 -07:00

20 lines
432 B
Go

package macutil
import (
"errors"
"syscall"
)
// CheckRosetta returns an error if the calling process is being translated
// by Apple Rosetta.
func CheckRosetta() error {
pt, err := syscall.Sysctl("sysctl.proc_translated")
if err != nil {
return nil
}
if len(pt) > 0 && pt[0] == 1 {
return errors.New("can not run under Rosetta, check that the installed build of Go is right for your CPU architecture")
}
return nil
}