osut

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 12 Imported by: 2

README

OS Utilities

  • OS Version
  • Name
  • Platform
  • OS Shell

Mac, Linux, Windows and Android

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoOpenCommand : When we don't know which command to use to open a file
	ErrNoOpenCommand = errors.New("unsure what command to use to open this file")
)

Functions

func Android

func Android() bool

func CallCmd added in v0.0.3

func CallCmd(command string) (string, error)

CallCmd execute local apps

func CallCmdNoWait added in v0.0.3

func CallCmdNoWait(command, app string) (int, error)

CallCmdNoWait execute app if not already running

func Distro

func Distro() string

func FVersion

func FVersion() string

func FindProcess added in v0.0.3

func FindProcess(appName string) (int, bool)

FindProcess find by application name return pid and if running true/false

func FullVer

func FullVer() string

func Hostname

func Hostname() string

func Linux

func Linux() bool

Linux is this Linux

func Mac

func Mac() bool

Mac is this a mac

func OSDistro

func OSDistro() string

func OSVersion

func OSVersion() (int, int)

OSVersion

func OSVersionMaj

func OSVersionMaj() int

func OSVersionMinor

func OSVersionMinor() int

func RunAppMac

func RunAppMac(app string) error

RunAppMac run application on mac

func RunAppNoPath

func RunAppNoPath(app string) error

RunAppNoPath run the application wherever you can find it

func RunAppWithPath

func RunAppWithPath(app, path string) ([]byte, error)

RunAppWithPath run the application with the specific path

func Windows

func Windows() bool

Windows is this windows?

Types

type OSCommand

type OSCommand struct {
	Log      *log.StdLogger
	Platform *Platform
}

OSCommand holds all the os commands

func NewOSCommand

func NewOSCommand(log *log.StdLogger) (*OSCommand, error)

NewOSCommand os command runner

func (*OSCommand) GetOpenCommand

func (c *OSCommand) GetOpenCommand() (string, string, error)

GetOpenCommand get open command

func (*OSCommand) OpenFile

func (c *OSCommand) OpenFile(filename string) (*exec.Cmd, error)

OpenFile opens a file with the given

func (*OSCommand) RunCommand

func (c *OSCommand) RunCommand(command string) error

RunCommand runs a command and just returns the error

func (*OSCommand) RunCommandWithOutput

func (c *OSCommand) RunCommandWithOutput(command string) (string, error)

RunCommandWithOutput wrapper around commands returning their output and error

type Platform

type Platform struct {
	OS           string
	OSAbbrv      string
	Arch         string
	Shell        *Shell
	VersionMajor int
	VersionMinor int
}

Platform stores the os state

func OS

func OS() *Platform
Example
fmt.Println("Win", Windows())
fmt.Println("Mac", Mac())
fmt.Println("Linux", Linux())
fmt.Println("Android", Android())

/*
		 Output:
		 Win false
	Mac true
	Linux false
	Android false
*/se
*/
Output:

			 Win false
		Mac true
		Linux false
		Android false

type Shell

type Shell struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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