Add hello world example

This commit is contained in:
lash
2023-04-17 06:35:36 +01:00
parent 100f7f3b48
commit afb3ff3a36
11 changed files with 48 additions and 29 deletions

View File

@@ -23,11 +23,20 @@ func main() {
ctx := context.Background()
en := engine.NewSizedEngine(dir, uint32(size))
err := en.Init(ctx)
cont, err := en.Init(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "engine init exited with error: %v\n", err)
os.Exit(1)
}
if !cont {
_, err = en.WriteResult(os.Stdout, ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "dead init write error: %v\n", err)
os.Exit(1)
}
os.Stdout.Write([]byte{0x0a})
os.Exit(0)
}
err = engine.Loop(&en, os.Stdin, os.Stdout, ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)