Drive systemd-journald the way journalctl --sync, --rotate, --flush
and --relinquish-var do. Every method takes no parameters and returns no
fields, so each generated method is just func(ctx) error.
// Command journal-control asks systemd-journald to flush, sync or rotate// its files, like `journalctl --sync` / `--rotate` / `--flush`. Requires// root.//// sudo go run ./examples/journal-control syncpackagemainimport("context""log""os""time""github.com/rossedman/sdvarlink/systemd/v257/journal")// main runs the example; see the package comment for usage.funcmain(){iflen(os.Args)!=2{log.Fatal("usage: journal-control sync|rotate|flush|relinquish")}ctx,cancel:=context.WithTimeout(context.Background(),30*time.Second)defercancel()c,err:=journal.Dial(ctx)iferr!=nil{log.Fatal(err)}deferc.Close()switchos.Args[1]{case"sync":err=c.Synchronize(ctx)case"rotate":err=c.Rotate(ctx)case"flush":err=c.FlushToVar(ctx)case"relinquish":err=c.RelinquishVar(ctx)default:log.Fatalf("unknown action %q",os.Args[1])}iferr!=nil{log.Fatal(err)}log.Printf("journald: %s done",os.Args[1])}