pixelweaver/config.go

32 lines
671 B
Go
Raw Normal View History

package main
import (
"encoding/json"
"fmt"
"os"
)
type Config struct {
Method string `json:method`
OutputDir string `json:outputdir`
2022-05-01 09:48:37 +02:00
InputDir string `json:inputdir`
BaseImage string `json:baseimage`
}
// loads configuration values from json file
func (c *Config) LoadConfigFromFile(filePath string) {
file, _ := os.Open("conf.json")
defer file.Close()
decoder := json.NewDecoder(file)
configuration := Config{}
err := decoder.Decode(&configuration)
if err != nil {
fmt.Println("error:", err)
}
fmt.Println(configuration.Method)
fmt.Println(configuration.OutputDir)
}
// global register to acccess configuration values
var ConfigRegister Config