MCPcopy Index your code
hub / github.com/rilldata/rill / IsWSL

Function IsWSL

cli/pkg/envdetect/envdetect.go:11–22  ·  view source on GitHub ↗

IsWSL returns true if the current environment is Windows Subsystem for Linux

()

Source from the content-addressed store, hash-verified

9
10// IsWSL returns true if the current environment is Windows Subsystem for Linux
11func IsWSL() bool {
12 // Check /proc/version for Microsoft signature
13 if versionFile, err := os.Open("/proc/version"); err == nil {
14 defer versionFile.Close()
15 scanner := bufio.NewScanner(versionFile)
16 if scanner.Scan() {
17 version := scanner.Text()
18 return strings.Contains(strings.ToLower(version), "microsoft")
19 }
20 }
21 return false
22}
23
24// IsOnWindowsPartition returns true if the current working directory is on a Windows partition
25// This is detected by checking if the path starts with /mnt/ (typical WSL mount point)

Callers 2

TestIsWSLFunction · 0.85
IsWSLWindowsPartitionFunction · 0.85

Calls 4

ContainsMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65
ScanMethod · 0.65

Tested by 1

TestIsWSLFunction · 0.68