JOJ3/internal/parsers/dummy/parser.go

36 lines
714 B
Go

package dummy
import (
"fmt"
"log/slog"
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
"github.com/criyle/go-judge/cmd/go-judge/model"
"github.com/mitchellh/mapstructure"
)
type Config struct {
Score int
Comment string
}
type Dummy struct{}
func (e *Dummy) Run(result *model.Result, configAny any) (
*stage.ParserResult, error,
) {
var config Config
err := mapstructure.Decode(configAny, &config)
if err != nil {
slog.Error("failed to decode config", "err", err)
return nil, err
}
return &stage.ParserResult{
Score: config.Score,
Comment: fmt.Sprintf(
"%s, executor status: run time: %d ns, memory: %d bytes",
config.Comment, result.RunTime, result.Memory,
),
}, nil
}