cross

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: MIT Imports: 4 Imported by: 14

README

Cross

Cross-platform functions I use in some utilities.

Functions

SetBasePath()

This is called by init(). It builds the base directory, which in the case of Linux, BSD etc. is just the user's home directory, and on macOS it's ~/Library/Application Support/.

ConfigName(filename)

Returns a path suitable for command-line programs, combining the config path and the configuration file.

  • On Linux/*BSD this will be the absolute path of ~/.<program>/<filename>, and the program name will have spaces removed
  • On macOS it returns the absolute path of ~/Library/Application Support/<program>/<filename>, with any spaces intact
ServerConfigName(program, filename)
  • Linux/*BSD returns /etc/<program>/<filename>
  • macOS simply returns the output from GetConfigName()
Exists(path)

Checks for the existence of a path and return true or false.

DirExists(path)

Checks for the existence of a directory. A file at the same path would return false.

FileExists(path)

Checks for the existence of a file. A directory at the same path would return false.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasePath

func BasePath() string

func ConfigName

func ConfigName(filename string) string

GetConfigName gets the correct full path of the configuration file for command line tools.

func ConfigPath

func ConfigPath() string

func DirExists

func DirExists(path string) bool

DirExists checks for the existence of a directory. It will return false if a file with that name exists.

func Exists

func Exists(path string) bool

Exists checks for the existence of a file or directory.

func FileExists

func FileExists(path string) bool

FileExists checks for the existence of a file. It will return false if a directory with that name exists.

func IsRoot added in v0.4.0

func IsRoot() bool

func ServerConfigName

func ServerConfigName(program, filename string) string

GetServerConfigName gets the correct full path of the configuration file for servers.

func SetBasePath

func SetBasePath()

SetBasePath builds the appropriate path for saving program-specific directories.

func SetConfigPath

func SetConfigPath(program string)

SetConfigPath builds the path to the command line program config directory.

func SetServerConfigPath added in v0.5.0

func SetServerConfigPath(program string)

SetServerConfigPath builds the path to the server config directory, bypassing automatically selected paths.

Types

This section is empty.

Jump to

Keyboard shortcuts

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