camlistore.org: camlistore.org/pkg/osutil Index | Files | Directories

package osutil

import "camlistore.org/pkg/osutil"

Package osutil provides operating system-specific path information, and other utility functions.

Index

Package Files

cpu.go cpu_linux.go findproc_normal.go mem.go mem_unix.go openurl.go osutil.go paths.go restart_unix.go syscall.go syscall_posix.go

Variables

var ErrNotSupported = errors.New("operation not supported")

ErrNotSupported is returned by functions (like Mkfifo and Mksocket) when the underlying operating system or environment doesn't support the operation.

func AddSecretRingFlag Uses

func AddSecretRingFlag()

AddSecretRingFlag registers the "secret-keyring" flag, accessible via ExplicitSecretRingFile.

func CPUUsage Uses

func CPUUsage() time.Duration

CPUUsage returns how much cumulative user CPU time the process has used. On unsupported operating systems, it returns zero.

func CacheDir Uses

func CacheDir() string

func CamliBlobRoot Uses

func CamliBlobRoot() string

func CamliConfigDir Uses

func CamliConfigDir() string

func CamliVarDir Uses

func CamliVarDir() string

func DefaultLetsEncryptCache Uses

func DefaultLetsEncryptCache() string

DefaultLetsEncryptCache returns the path to the default Let's Encrypt cache directory (or file, depending on the ACME implementation).

func DefaultSecretRingFile Uses

func DefaultSecretRingFile() string

DefaultSecretRingFile returns the path to the default GPG secret keyring. It is not influenced by any flag or CAMLI* env var.

func DefaultTLSCert Uses

func DefaultTLSCert() string

DefaultTLSCert returns the path to the default TLS certificate file that is used (creating if necessary) when TLS is specified without the cert file.

func DefaultTLSKey Uses

func DefaultTLSKey() string

DefaultTLSKey returns the path to the default TLS key file that is used (creating if necessary) when TLS is specified without the key file.

func DieOnParentDeath Uses

func DieOnParentDeath()

DieOnParentDeath starts a goroutine that regularly checks that the current process can find its parent, and calls os.Exit(0) as soon as it cannot.

func DirExists Uses

func DirExists(dir string) bool

DirExists reports whether dir exists. Errors are ignored and are reported as false.

func ExplicitSecretRingFile Uses

func ExplicitSecretRingFile() (string, bool)

ExplicitSecretRingFile returns the path to the user's GPG secret ring file and true if it was ever set through the --secret-keyring flag or the CAMLI_SECRET_RING var. It returns "", false otherwise. Use of this function requires the program to call AddSecretRingFlag, and before flag.Parse is called.

func GoPackagePath Uses

func GoPackagePath(pkg string) (path string, err error)

GoPackagePath returns the path to the provided Go package's source directory. pkg may be a path prefix without any *.go files. The error is os.ErrNotExist if GOPATH is unset or the directory doesn't exist in any GOPATH component.

func HasSecretRingFlag Uses

func HasSecretRingFlag() bool

HasSecretRingFlag reports whether the "secret-keywring" command-line flag was registered. If so, it is safe to use ExplicitSecretRingFile.

func HomeDir Uses

func HomeDir() string

HomeDir returns the path to the user's home directory. It returns the empty string if the value isn't known.

func MaxFD Uses

func MaxFD() (uint64, error)

MaxFD returns the maximum number of open file descriptors allowed. It returns ErrNotSupported on unsupported systems.

func MemUsage Uses

func MemUsage() int64

MemUsage returns the number of bytes used by the process. On unsupported operating systems, it returns zero.

func Mkfifo Uses

func Mkfifo(path string, mode uint32) error

Mkfifo creates a FIFO file named path. It returns ErrNotSupported on unsupported systems.

func Mksocket Uses

func Mksocket(path string) error

Mksocket creates a socket file (a Unix Domain Socket) named path. It returns ErrNotSupported on unsupported systems.

func NewJSONConfigParser Uses

func NewJSONConfigParser() *jsonconfig.ConfigParser

NewJSONConfigParser returns a jsonconfig.ConfigParser with its IncludeDirs set with CamliConfigDir and the contents of CAMLI_INCLUDE_PATH.

func OpenURL Uses

func OpenURL(url string) error

func RegisterConfigDirFunc Uses

func RegisterConfigDirFunc(f func() string)

RegisterConfigDirFunc registers a func f to return the Camlistore configuration directory. It may skip by returning the empty string.

func RegisterLetsEncryptCacheFunc Uses

func RegisterLetsEncryptCacheFunc(f func() string)

RegisterLetsEncryptCacheFunc registers a func f to return the path to the default Let's Encrypt cache. It may skip by returning the empty string.

func RestartProcess Uses

func RestartProcess(arg ...string) error

RestartProcess restarts the process with the given arguments, if any, replacing the original process's arguments. It defaults to os.Args otherwise. It returns an error if things couldn't be restarted. On success, this function never returns because the process becomes the new process.

func SecretRingFile Uses

func SecretRingFile() string

SecretRingFile returns the path to the user's GPG secret ring file. The value comes from either the --secret-keyring flag (if previously registered with AddSecretRingFlag), or the CAMLI_SECRET_RING environment variable, or the operating system default location.

func SelfPath Uses

func SelfPath() (string, error)

SelfPath returns the path of the executable for the currently running process. At least on linux, the returned path is a symlink to the actual executable.

func UserClientConfigPath Uses

func UserClientConfigPath() string

func UserServerConfigPath Uses

func UserServerConfigPath() string

func Username Uses

func Username() string

Username returns the current user's username, as reported by the relevant environment variable.

Directories

PathSynopsis
gcePackage gce configures hooks for running Camlistore for Google Compute Engine.

Package osutil imports 14 packages (graph) and is imported by 573 packages. Updated 2018-01-11. Refresh now. Tools for package owners.