util

package
v0.0.0-...-555310e Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateByteFile

func CreateByteFile(data []byte, fullpath string, allowOverwrite bool) error

CreateByteFile takes a slice of bytes & writes its contents to disk at fullpath using an io.Writer if the file does not already exist. If the file exists and allowOverwrite is true then it will overwrite the existing file.

func CreateDirectory

func CreateDirectory(dirname string) error

CreateDirectory attempts to create a directory with given dirname if it does not already exist. If it already exists, then the function does nothing.

func CreateEmptyFile

func CreateEmptyFile(fullpath string, allowOverwrite bool) error

CreateEmptyFile wraps os.Create and creates and empty file with at fullpath if it does not exist. If the file at fullpath exists, and allowOverwrite is true then it will overwrite the existing file.

func DirExists

func DirExists(dir string) bool

DirExists returns true if the directory dir exists; otherwise returns false.

func FileExists

func FileExists(name string) bool

FileExists returns true if the file of name exists; otherwise returns false.

func ReadTillNul

func ReadTillNul(b []byte) string

ReadTillNul takes a slice of bytes b and reads up until it encounters the first null terminator, returning the bytes read up until that point as a string.

func WriteJSONConfig

func WriteJSONConfig(cfg interface{}, directory, fullpath string) error

WriteJSONConfig takes an empty interface cfg, which is meant to be a *config.Config struct or a *GameList and writes it as JSON to disk at fullpath, overwriting any existing file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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