package main
import (
"context"
"os"
"strconv"
"strings"
"github.com/pancsta/asyncmachine-go/tools/generator"
"github.com/pancsta/asyncmachine-go/tools/generator/cli"
)
const (
flights = 10
gates = 5
)
func main() {
ctx := context .Background ()
params := cli .SFParams {
Name : "Flights" ,
Inherit : "rpc/worker,basic" ,
}
for i := 1 ; i <= flights ; i ++ {
numF := strconv .Itoa (i )
flight := "Flight" + numF
params .States += ","
params .Groups += ","
params .States += flight + "OnTime:remove(_" + flight + "Status)," +
flight + "Delayed:remove(_" + flight + "Status)," +
flight + "Departed:remove(_" + flight + "Status;" + flight + "GoToGate)," +
flight + "Arrived:remove(_" + flight + "Status)," +
flight + "Scheduled:auto:remove(_" + flight + "Status)," +
flight + "Inbound:remove(_" + flight + "Direction)," +
flight + "Outbound:remove(_" + flight + "Direction)," +
flight + "GoToGate:require(" + flight + "Outbound)," +
flight + "GateUnknown:auto,"
params .Groups += flight + "Direction(" +
flight + "Inbound;" + flight + "Outbound),"
params .Groups += flight + "Status(" +
flight + "OnTime;" + flight + "Delayed;" + flight + "Departed;" + flight + "Arrived;" + flight + "Scheduled),"
params .Groups += flight + "Gates("
for ii := 1 ; ii <= gates ; ii ++ {
numG := strconv .Itoa (ii )
gate := flight + "Gate" + numG
params .States += gate + ":remove(_" + flight + "Gates),"
params .Groups += gate + ";"
}
params .Groups = strings .TrimRight (params .Groups , ";" ) + "),"
}
gen , err := generator .NewSchemaGenerator (ctx , params )
if err != nil {
panic (err )
}
out := gen .Output ()
err = os .WriteFile ("../states/ss_flights.go" , []byte (out ), 0644 )
if err != nil {
panic (err )
}
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .