utils

package
v0.0.0-...-c4ec94d Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EditorLaunchCommands = map[string]string{
	"vim":      "vim",
	"nvim":     "nvim",
	"emacs":    "emacs",
	"vscode":   "code --wait",
	"atom":     "atom --wait",
	"sublime":  "subl -n -w",
	"phpstorm": "phpstorm --wait",
	"pstorm":   "pstorm --wait",
}

EditorLaunchCommands are the commands used to open a file in a specified text editor and wait for the file to be saved to close

Functions

func BashExec

func BashExec(cmd string) (string, error)

BashExec executes a command appended to a 'bash -c' command

func CreateDir

func CreateDir(path string) error

CreateDir creates a directory if it does not exist

func CreateFile

func CreateFile(path string) error

CreateFile creates a file if it does not exist

func DirExists

func DirExists(path string) bool

DirExists checks for whether a directory exists

func ExecuteCommand

func ExecuteCommand(cmd *exec.Cmd) string

ExecuteCommand runs an external shell command

func ExitWithError

func ExitWithError(msg interface{})

ExitWithError prints a clear error and exits the program

func FileExists

func FileExists(path string) bool

FileExists checks for whether a file exists

func GetKeysFromMapString

func GetKeysFromMapString(m map[string]string) (keys []string)

GetKeysFromMapString returns the values of a map[string]string keys as a slice of strings

func GetKeysFromMapStringInterface

func GetKeysFromMapStringInterface(m map[string]interface{}) (keys []string)

GetKeysFromMapStringInterface parses keys from a map[string]interface

func GetPHPStormExecutable

func GetPHPStormExecutable() (string, error)

GetPHPStormExecutable checks for which phpstorm executable is set in their PATH to determine the launch command to use

func GetPlatform

func GetPlatform() string

GetPlatform returns the OS platform of the current machine

func OpenURLInDefaultBrowser

func OpenURLInDefaultBrowser(url string) error

OpenURLInDefaultBrowser launches the user system's default browser with a given URL as the target

func PrintError

func PrintError(msg interface{})

PrintError outputs a standard error message to the user's console

func ValidateURL

func ValidateURL(path string) (string, error)

ValidateURL accepts a path and validates it as a url

Types

This section is empty.

Jump to

Keyboard shortcuts

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