Add documentation

This commit is contained in:
Thorsten Sommer committed 2015-06-17 17:44:52 +02:00
1 parent 69d0bdabf4
commit 6dab89a1d4
144 files changed
+1107 -549

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
package Configuration
// This is the init function for this package.
func init() {
readConfiguration()
isInit = true
+5 -2
View File
@@ -8,8 +8,8 @@ import (
"path/filepath"
)
// Function to read the configuration file.
func readConfiguration() {
if isInit {
Log.LogFull(senderName, Meta.CategorySYSTEM, Meta.LevelWARN, Meta.SeverityNone, Meta.ImpactNone, Meta.MessageNameINIT, `The configuration package is already init!`)
return
@@ -17,13 +17,14 @@ func readConfiguration() {
Log.LogShort(senderName, Meta.CategorySYSTEM, Meta.LevelINFO, Meta.MessageNameCONFIGURATION, `Init of configuration starting.`)
}
// Access to the working directory?
currentDir, dirError := os.Getwd()
if dirError != nil {
panic(`Was not able to read the working directory: ` + dirError.Error())
return
}
// Access to the configuration file?
currentPath := filepath.Join(currentDir, filename)
if _, errFile := os.Stat(currentPath); errFile != nil {
if os.IsNotExist(errFile) {
@@ -33,6 +34,7 @@ func readConfiguration() {
}
}
// Open the file:
file, fileError := os.Open(currentPath)
defer file.Close()
@@ -41,6 +43,7 @@ func readConfiguration() {
return
}
// Try to decode / parse the file:
decoder := json.NewDecoder(file)
decError := decoder.Decode(&configuration)
+4 -4
View File
@@ -6,8 +6,8 @@ import (
)
var (
filename = "configuration.json" // Where is the configuration located?
configuration Meta.Configuration = Meta.Configuration{} // The loaded configuration
isInit = false // Is the configuration loaded?
senderName LM.Sender = `System::Configuration`
filename = "configuration.json" // Where is the configuration located?
configuration Meta.Configuration = Meta.Configuration{} // The loaded configuration
isInit = false // Is the configuration loaded?
senderName LM.Sender = `System::Configuration` // This is the name for logging event from this package
)