utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2017 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ASSET_ROOT_DIR = "assets"

the root asset directory where all the external files used are stored

Variables

This section is empty.

Functions

func AssetPath

func AssetPath(assetName string) (string, error)

AssetPath will return the relative path to the file represented by assetName otherwise it will return an error if the file doesn't exist.

func ExternalIPAddress

func ExternalIPAddress() (string, error)

ExternalIPAddress will get this current computer's external IP address. credit to: https://gist.github.com/jniltinho/9788121

func FullDateString

func FullDateString() string

FullDateString will return the current time formatted as a string.

func FullDateStringSafe

func FullDateStringSafe() string

FullDateStringSafe returns the current time as a string with only file-name safe characters. Used to quickly and easily generate unique file names based off of the current system time.

func ReadLines

func ReadLines(path string) ([]string, error)

ReadLines reads in a file by path and returns a slice of strings credit to: https://stackoverflow.com/a/18479916/584947

func SysAssetPath

func SysAssetPath(assetName string) (string, error)

SysAssetPath will return the relative path to the file represented by assetName but also add in the GOOS after the filename and before the extension. This allows loading system-specific files with one command instead of a complicated switch statement every time. For instance if your GOOS == "linux" then you can open "config_linux.json" by just asking for "config.json". This is extremely powerful and a core component of loading system-specific shell commands based on the current GOOS.

func TimeStampFileName

func TimeStampFileName(fileBaseName string, fileExtension string) string

TimeStampFileName will generate a string to be used to uniquely name and identify a new file. The characters used in the file name are guaranteed to be safe for a file. The given fileBaseName will be used to append to the beginning of the file name to give some control over the file name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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