Initial commit

This commit is contained in:
Miguel de la Cruz 2024-05-25 11:26:55 +02:00
parent 354ad8811c
commit b7d8b94d46
4 changed files with 61 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/bin/

7
Makefile Normal file
View file

@ -0,0 +1,7 @@
build:
rm -rf bin
mkdir bin
go build -o bin ./...
check:
go fmt ./...

50
cmd/bookworm/bookworm.go Normal file
View file

@ -0,0 +1,50 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
)
type Config struct {
MinifluxURL string `json:"miniflux_url"`
MinifluxAPI string `json:"miniflux_api"`
MinifluxCategory string `json:"miniflux_category"`
}
func (c *Config) IsValid() error {
return nil
}
func ReadConfig(name string) (*Config, error) {
b, err := os.ReadFile(name)
if err != nil {
return nil, err
}
var cfg Config
if err := json.Unmarshal(b, &cfg); err != nil {
return nil, err
}
return &cfg, nil
}
func checkErr(err error) {
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}
func main() {
cfgFlag := flag.String("config", "bookworm.json", "path to the configuration file")
flag.Parse()
cfg, err := ReadConfig(*cfgFlag)
checkErr(err)
cErr := cfg.IsValid()
checkErr(cErr)
}

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module git.ctrlz.es/mgdelacroix/bookworm
go 1.21.9