xplat

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 8 Imported by: 7

Documentation

Overview

Helper methods for supporting cross-platform shells.

This takes into account both the operating system and the shell environment that the process is running within. The following environments are supported: * Linux * MacOS * Windows with WSL/PowerShell/CMD/Git Bash (mingw)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectShell

func DetectShell() string

DetectShell uses environment variables to determine the containing shell environment.

Values: unknown, posix, mingw, powershell, cmd, $SHELL (e.g. sh, bash)

This is not guaranteed to always work depending on customizations to the default Windows environment variables. It uses the following heuristics: * MSYSTEM is set * SHELL is set * PSModulePath containing user's home directory

func EnsureInPath

func EnsureInPath(value string)

EnsureInPath adds the specified path to the beginning of the PATH environment variable when it is already in PATH.

func FilePathJoin

func FilePathJoin(elem ...string) string

FilePathJoin elements accounting for the operating system _and_ shell. For example, on Windows with MingW the path is formatted in the linux-style.

func GOPATH

func GOPATH() string

GOPATH returns the current GOPATH that is safe to use on any OS, including when run through Git Bash (mingw).

func GetMSystem

func GetMSystem() string

GetMSystem returns current the MSys2 subsystem.

Allowed values are: (empty), mingw32, mingw64, msys2.

func InPath

func InPath(value string) bool

InPath determines if the path is in the PATH environment variable.

func IsMSys2

func IsMSys2() bool

IsMSys2 detects if the current shell is an installation of unix-like environment, such as Git Bash.

func PathListSeparator

func PathListSeparator() rune

PathListSeparator determines the PATH separator that is safe to use on any OS, including when run through Git Bash (mingw).

func PathSeparator

func PathSeparator() rune

PathSeparator determines the correct path separator based on the operating system _and_ shell.

For example, on Windows with Git Bash (mingw) the path is formatted linux-style.

func PrependPath

func PrependPath(value string)

PrependPath adds the specified path to the beginning of the PATH environment variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL