Added -i for Input File

This commit is contained in:
simon 2025-05-19 21:04:54 +02:00
parent ac5c660583
commit e80cba9110

View File

@ -18,6 +18,7 @@ var appConfig = koanf.New(".")
func main() { func main() {
confPath := flag.String("c", "testdata/conf.yaml", "Config File") confPath := flag.String("c", "testdata/conf.yaml", "Config File")
outFileName := flag.String("o", "", "Name of the Output File") outFileName := flag.String("o", "", "Name of the Output File")
inputFile := flag.String("i", "testdata/prot1.json", "Name of the Input File")
flag.Parse() flag.Parse()
@ -27,7 +28,11 @@ func main() {
log.Printf("CONF: %v", appConfig) log.Printf("CONF: %v", appConfig)
} }
file, _ := os.ReadFile("testdata/prot1.json") file, err := os.ReadFile(*inputFile)
if err != nil {
log.Printf("ERROR: %v", err)
return
}
var cfg proto.Proto var cfg proto.Proto
json.Unmarshal(file, &cfg) json.Unmarshal(file, &cfg)