Documentation ¶
Overview ¶
The wslcheck package provides a simple function that checks whether the current Linux environment is in fact the Windows Subsystem for Linux (WSL).
Index ¶
Examples ¶
Constants ¶
View Source
const ( // Path to `/proc` pseudo-file that shows release info ProcReleasePath = "/proc/sys/kernel/osrelease" // Regular expression used to test against the output of ProcReleasePath VersionRegexp = `.*microsoft-standard.*|.*Microsoft.*` )
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check returns true if the Linux version string matches that of a WSL distribution. Otherwise (including when the host OS is not Linux at all), it returns false.
If an error occurs when attempting to get the version string, Check will return false and the error value will be populated (not-nil).
Example ¶
The simplest possible use of this function
package main import ( "fmt" "github.com/e-zk/wslcheck" ) func main() { fmt.Println("Am I running on WSL?") wsl, _ := wslcheck.Check() if wsl == true { fmt.Println("Yes!") } else { fmt.Println("No!") } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.