blechelse-go/main.go
2025-03-30 13:30:40 +02:00

49 lines
1.3 KiB
Go

package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
)
// Config represents the structure of the config.json file.
type Config struct {
BaseDir string `json:"Base_Dir"`
Modules []Module `json:"Modules"`
}
// Module represents a module entry in the config.json file.
type Module struct {
Name string `json:"Name"`
Path string `json:"Path"`
CSVFile string `json:"CSVFile"`
DefaultLanguage string `json:"Default_Language"`
DefaultVariants []string `json:"Default_Variants"`
}
func main() {
// Open the config.json file
configFilePath := "config.json"
data, err := ioutil.ReadFile(configFilePath)
if err != nil {
log.Fatalf("Error reading file: %v", err)
}
// Parse the JSON data into a Config struct
var config Config
err = json.Unmarshal(data, &config)
if err != nil {
log.Fatalf("Error parsing JSON: %v", err)
}
// Print the parsed configuration
fmt.Printf("Base Dir: %s\n", config.BaseDir)
for _, module := range config.Modules {
fmt.Printf("Module Name: %s\n", module.Name)
fmt.Printf(" Path: %s\n", module.Path)
fmt.Printf(" CSV File: %s\n", module.CSVFile)
fmt.Printf(" Default Language: %s\n", module.DefaultLanguage)
fmt.Printf(" Default Variants: %v\n", module.DefaultVariants)
}
}