sys

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Unknown OS was not detected
	Unknown = iota
	// Osx Os
	Osx
	// Linux Os
	Linux
	// Windows Os
	Windows
)
View Source
const NewLine = "\n"

NewLine is a constant string representing a new line - platform dependent

Variables

View Source
var ExecuteStreamingToStdout = false

ExecuteStreamingToStdout is used to silence command output in the ExecuteOutputWriter below

Functions

func DirSize

func DirSize(path string) (string, error)

DirSize returns a human readable form of the size of the directory at path

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile downloads the file at url and saves it to filepath

func Execute

func Execute(filename string, args ...string) (string, error)

Execute runs a command naked

func ExecuteEx

func ExecuteEx(filename string, directoryName string, environment bool, args ...string) (string, error)

ExecuteEx runs a command and allows to set its working directory or pass the user environment to the command

func ExecuteOutputWriter

func ExecuteOutputWriter(r io.Reader)

ExecuteOutputWriter is called the go routines above to stream to stdout TODO: parameterize output channel, etc

func FmtDuration

func FmtDuration(duration time.Duration) string

FmtDuration formats a time.Duration into a human readable form

func GetHome

func GetHome() (string, error)

GetHome returns the fullpasth to the user's home directory

func MkDir

func MkDir(path string) error

MkDir creates the directory at path and all subdirectories

func Pwd

func Pwd() (string, error)

Pwd returns the current directory's full path

func SedFile

func SedFile(filename string, regex string, newContent string)

SedFile searches regex inside filename and replaces it by newContent

Types

type Os

type Os int

Os represents the operating system the code in running on

func GetOs

func GetOs() (Os, error)

GetOs returns the Os enum representing the currently running operating system

func (Os) Name

func (o Os) Name() string

Name is the operating system lowercase name / identifier

func (Os) String

func (o Os) String() string

func (Os) Title

func (o Os) Title() string

Title is the operating system pretty name

Jump to

Keyboard shortcuts

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