go-judge/runner/run.go
criyle 1f86f25995 Refactor & Documentation
- pkg/runner -> pkg/envexec
- add idea about executor server
2020-03-03 02:32:59 -05:00

28 lines
530 B
Go

package runner
import (
"fmt"
"github.com/criyle/go-judge/file"
"github.com/criyle/go-judge/problem"
)
const maxOutput = 4 << 20 // 4M
func (r *Runner) run(done <-chan struct{}, task *RunTask) *RunTaskResult {
switch task.Type {
case problem.Compile:
return r.compile(done, task.Compile)
default:
return r.exec(done, task.Exec)
}
}
func getFile(files map[string]file.File, name string) ([]byte, error) {
if f, ok := files[name]; ok {
return f.Content()
}
return nil, fmt.Errorf("file %s not exists", name)
}