pos

package
v0.4.145 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: ISC Imports: 10 Imported by: 5

Documentation

Overview

Package parlos provides simplified functions for home-directory and hostname.

Index

Constants

View Source
const (
	StatusCodeErr   = 1
	StatusCodeUsage = 2
)
View Source
const (
	// when created, output file permissions is user-read/write
	FilePermUrw os.FileMode = 0o600 // rw- --- ---

)

Variables

This section is empty.

Functions

func AppDir added in v0.4.24

func AppDir(appName string) (directory string)

AppDir gets an app-specific writable file-system directory

  • “~/.local/share/appName”
  • ensures the directory exists with user-only permissions

func AppendToFile added in v0.4.114

func AppendToFile(filename string) (osFile *os.File, err error)

func ExecDir added in v0.4.24

func ExecDir() (dir string)

ExecDir gets abolute path to directory where executable is located

func Exit

func Exit(code int, err error)

Exit terminate the command echoing to stderr returning status code

func Exit0

func Exit0()

Exit0 terminates the process successfully

func Exit1

func Exit1(err error)

Exit1 terminate the command echoing a failure to stderr and returning status code 1

func Exit1OneLine

func Exit1OneLine(err error)

Exit1OneLine terminate the command echoing to stderr returning status code 1

func HomeDir

func HomeDir(relPaths string) (dir string)

HomeDir creates levels of directories in users’s home. if directories do not exist, they are created with permissions u=rwx. This should never fail, when it does, panic is thrown

func OsExit

func OsExit(code int)

OsExit does os.Exit

func ParentDir added in v0.4.24

func ParentDir() (dir string)

ParentDir gets absolute path of executable parent directory

func ShortHostname

func ShortHostname() (host string)

ShortHostname gets hostname without domain part This should never fail, when it does, panic is thrown

func UserHome added in v0.4.127

func UserHome() (homeDir string, err error)

UserHome obtains the absolute path to the process owning user’s home directory

  • does not rely on environment

func UserHomeDir

func UserHomeDir() (homeDir string)

UserHomeDir obtains the absolute path to the process owning user’s home directory

  • does not rely on environment
  • should never fail. if it does, panic is thrown

Types

type AppDirectory added in v0.4.24

type AppDirectory struct {
	App string // app name like “myapp”
}

AppDirectory manages a per-user writable app-specific directory

func NewAppDir added in v0.4.24

func NewAppDir(appName string) (appd *AppDirectory)

NewAppDir returns an object providing an app-specific file system location with defered directory creation

func (*AppDirectory) Directory added in v0.4.24

func (appd *AppDirectory) Directory() (directory string)

Directory returns the app’s writable directory

  • “~/.local/share/appName”
  • ensures the directory exists with user-only permissions

func (*AppDirectory) Path added in v0.4.127

func (appd *AppDirectory) Path() (directory string, err error)

Path returns the path to the directory without panics or file-system writes

Jump to

Keyboard shortcuts

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