IsWSL returns true if Windows Subsystem for Linux is detected. "Official" way of detecting WSL https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364
()
| 29 | // "Official" way of detecting WSL |
| 30 | // https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364 |
| 31 | func IsWSL() bool { |
| 32 | b, err := os.ReadFile("/proc/sys/kernel/osrelease") |
| 33 | if err != nil { |
| 34 | return false |
| 35 | } |
| 36 | return strings.Contains(strings.ToLower(string(b)), "microsoft") || strings.Contains(strings.ToLower(string(b)), "wsl") |
| 37 | } |
| 38 | |
| 39 | // Exec is wrapper over syscall.Exec, invokes the execve(2) system call. On |
| 40 | // windows it executes Run with the same arguments. |
no outgoing calls
no test coverage detected
searching dependent graphs…