Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorReadConfigFailed = errors.New("Unable to read config") ErrorUnmarshalConfigFailed = errors.New("Unable to unmarshal config") ErrorMarshalConfigFailed = errors.New("Unable to marshal config") ErrorWriteConfigFailed = errors.New("Unable to write config") ErrorConfigFileUnset = errors.New("Config file wasn't set prior to call") )
Functions ¶
func FileExists ¶
FileExists checks to see if a file exists and returns true if it exists
Example ¶
if FileExists("filesystemExist_test.go") { log.Println("Just making sure I'm still here") } else { log.Fatalln("We seem to have disappeared") }
Output:
func FileNotExist ¶
FileNotExist checks to see if a file exists and returns false if it exists
Example ¶
if FileNotExist("DoesNotExist.here") { log.Println("The file doesn't exist... Cool!") } else { log.Fatalln("This file shouldn't exist") }
Output:
func FolderExists ¶
FolderExists checks to see if a dir exists and returns true if it exists
Example ¶
if FolderExists("../GoEssentials") { log.Println("Just checking in on my parent") } else { log.Fatalln("Where'd Go go this time") }
Output:
func FolderNotExist ¶
FolderNotExist checks to see if a dir exists and returns false if it exists
Example ¶
if FolderNotExist("DoesNotExist") { log.Println("It'd be weird if that directory was a thing anyway") } else { log.Fatalln(`Did you just create a directory called "DoesNotExist"?`) }
Output:
func GetConfig ¶
GetConfig fetches the config located at 'configFileName' and puts its parsed contents into 'configPointer' if the config doesn't exist, it's created with the default from 'configPointer' and returns the error 'ErrorConfigFileUnset'
Example ¶
ExampleGetConfig provides a simple example
package main import ( "log" ) type ExampleConfig struct { Works bool } // This both serves as the default configuration // and a global config variable. If you don't // want your config to be globally accessable, // you could also define this somewhere else. var config = ExampleConfig{ Works: true, } // ExampleGetConfig provides a simple example func main() { err := GetConfig("exampleConfig.json", &config) if err != nil && err != ErrorConfigFileUnset { log.Fatalln(err) } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.