first commit
This commit is contained in:
commit
3621c11a61
5 changed files with 97 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
modules/*
|
||||
!mdules/*.csv
|
||||
main
|
19
config.json
Normal file
19
config.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"Base_Dir": "modules",
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "Abschnitte",
|
||||
"Path": "abschnitte",
|
||||
"CSVFile": "abschnitte.csv",
|
||||
"Default_Language": "dt",
|
||||
"Default_Variants": ["hoch"]
|
||||
},
|
||||
{
|
||||
"Name": "Gleise",
|
||||
"Path": "gleise_zahlen",
|
||||
"CSVFile": "gleise_zahlen.csv",
|
||||
"Default_Variants": ["hoch"],
|
||||
"Default_Language": "dt"
|
||||
}
|
||||
]
|
||||
}
|
10
go.mod
Normal file
10
go.mod
Normal file
|
@ -0,0 +1,10 @@
|
|||
module main
|
||||
|
||||
go 1.24.1
|
||||
|
||||
require github.com/posener/complete v1.2.3
|
||||
|
||||
require (
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.0.0 // indirect
|
||||
)
|
16
go.sum
Normal file
16
go.sum
Normal file
|
@ -0,0 +1,16 @@
|
|||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
49
main.go
Normal file
49
main.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue