Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vn-ki/go-judge
A judge (?) written in go.
https://github.com/vn-ki/go-judge
Last synced: about 2 months ago
JSON representation
A judge (?) written in go.
- Host: GitHub
- URL: https://github.com/vn-ki/go-judge
- Owner: vn-ki
- License: mit
- Created: 2018-05-18T12:56:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T14:23:58.000Z (about 6 years ago)
- Last Synced: 2024-10-15T12:49:22.224Z (3 months ago)
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-judge
[![GoDoc](https://godoc.org/github.com/vn-ki/go-judge?status.svg)](https://godoc.org/github.com/vn-ki/go-judge)
[![Build Status](https://travis-ci.com/vn-ki/go-judge.svg?branch=master)](https://travis-ci.com/vn-ki/go-judge)
[![codecov](https://codecov.io/gh/vn-ki/go-judge/branch/master/graph/badge.svg)](https://codecov.io/gh/vn-ki/go-judge)A go package which (compiles and) executes a program and checks it with given of inputs. This can be used to build an online judge (or a web IDE).
### Supported Languages
- C++
- Python 3
- Python 2```go
package mainimport (
"fmt"
gojudge "github.com/vn-ki/go-judge/judge"
)func main() {
judge := gojudge.GetCPPJudge(gojudge.Config{})
judge.AddSourceFile("a.cpp")
judge.AddInputFile("input1.txt")
out, err := judge.Output()
if err != nil {
panic(err)
}
fmt.Println(out)
}```
You can remove the use of `AddSourceFile` and `AddInputFile` by using [`Config`](https://godoc.org/github.com/vn-ki/go-judge#Config).
```go
judge := gojudge.GetCPPJudge(gojudge.Config{
SourceFile: "a.cpp",
InputFiles: []string{"input1.txt"},
})
```See [documentation](https://godoc.org/github.com/vn-ki/go-judge#Judge) for more info on `Judge`.
## How to add more languages
- Make a new file under `go-judge/judge` in the following format
```go
package judge/*
GetLanguageRunner returns a Runner with Language configuration
*/
func GetLanguageRunner(config Config) Judge {
return addConfig(
Judge{
compileCmd: "LanguageCompiler",
compileArgs: []string{"--compile-lang", "{source_file}"},
runCmd: "./{compiled_program}",
runArgs: []string{},
compileBeforeRun: true,
extension: ".lang",
}, config)
}```
- Profit!!
### TODO
- Support more languages
- Check output
- Write tests
- Add support for compiler flags