Read config from file in command line arguments

This commit is contained in:
Magnus Åhall 2026-05-26 10:09:24 +02:00
parent 40d1c388fd
commit 75d242c041
2 changed files with 2 additions and 4 deletions

View file

@ -3,7 +3,6 @@ package main
import (
// Standard
"encoding/json"
"fmt"
"os"
)
@ -27,9 +26,8 @@ type Config struct {
}
}
func readConfig() (err error) {
func readConfig(fname string) (err error) {
var configData []byte
fname := fmt.Sprintf("%s/.config/notes2.json", os.Getenv("HOME"))
configData, err = os.ReadFile(fname)
if err != nil {
return

View file

@ -75,7 +75,7 @@ func initLog() { // {{{
} // }}}
func main() { // {{{
initLog()
err := readConfig()
err := readConfig(FlagConfig)
if err != nil {
Log.Error("config", "error", err)
os.Exit(1)