system

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 8 Imported by: 14

Documentation

Overview

Package system contain some functions about os, runtime, shell command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareOsEnv

func CompareOsEnv(key, comparedEnv string) bool

CompareOsEnv gets env named by the key and compare it with comparedEnv

func ExecCommand

func ExecCommand(command string, opts ...Option) (stdout, stderr string, err error)

ExecCommand execute command, return the stdout and stderr string of command, and error if error occur param `command` is a complete command string, like, ls -a (linux), dir(windows), ping 127.0.0.1 in linux, use /bin/bash -c to execute command in windows, use powershell.exe to execute command

func GetOsBits added in v1.3.1

func GetOsBits() int

GetOsBits get this system bits 32bit or 64bit return bit int (32/64)

func GetOsEnv

func GetOsEnv(key string) string

GetOsEnv gets the value of the environment variable named by the key.

func IsLinux

func IsLinux() bool

IsLinux check if current os is linux

func IsMac

func IsMac() bool

IsMac check if current os is macos

func IsWindows

func IsWindows() bool

IsWindows check if current os is windows

func RemoveOsEnv

func RemoveOsEnv(key string) error

RemoveOsEnv remove a single environment variable.

func SetOsEnv

func SetOsEnv(key, value string) error

SetOsEnv sets the value of the environment variable named by the key.

Types

type Option added in v1.3.8

type Option func(*exec.Cmd)

func WithForeground added in v1.3.8

func WithForeground() Option

func WithWinHide added in v1.3.8

func WithWinHide() Option

Jump to

Keyboard shortcuts

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